Meteor iOS Martin 的 DDP 包,如何使用用户名登录

Meteor iOS DDP package by martin, how to login with username

我正在使用这个 DDP 包从我的 iOS 应用程序登录:

https://github.com/martijnwalraven/meteor-ios/

但我只能找到一个名为 loginWithEmail 的方法。

https://github.com/martijnwalraven/meteor-ios/blob/affe8d13a876a0e6e7c95656339d496cbc54a649/Meteor/METDDPClient%2BAccountsPassword.m

如何编辑它以便我可以使用用户名登录?

你必须自己制作方法。

找到 METDDPClient+AccountsPassword.h 和 .m

在.h你

- (void)loginWithUsername:(NSString *)username password:(NSString *)password completionHandler:(nullable METLogInCompletionHandler)completionHandler;

然后在 .m

- (void)loginWithUsername:(NSString *)username password:(NSString *)password completionHandler:(METLogInCompletionHandler)completionHandler{
   [self loginWithMethodName:@"login" parameters:@[@{@"user": @{@"username": username}, @"password": @{@"digest": [password SHA256String], @"algorithm": @"sha-256"}}] completionHandler:completionHandler];
}