测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可协议 | MIT |
发布最新发布 | 2015年6月 |
由Eugene Nguyen维护。
依赖 | |
XBCacheRequest | >= 0 |
JSONKit-NoWarning | >= 0 |
MD5Digest | >= 0 |
SDWebImage | >= 0 |
Facebook-iOS-SDK | >= 0 |
XBLanguage | >= 0 |
要运行示例项目,请克隆仓库,然后首先从示例目录运行pod install
。
XBAuthentication提供所有指向用户系统的功能,包括登录、注册、注销、编辑用户信息、删除账户。这是XBMobile的核心系统。
首先,在每个需要的地方导入XBAuthentication.h
其次,设置您的Web服务域名。
[[XBAuthentication sharedInstance] setHost:@"http://example.com"];
然后,设置您想要的字段。
XBAuthentication *authenticator = [XBAuthentication sharedInstance];
authenticator.username = @"username";
authenticator.password = @"password";
最后,按需登录或注册。
[authenticator signup];
// OR, remember, OR, not AND
[authenticator signin];
您可以使用以下功能进行下一步操作:
// Forgot password (with username or email)
- (void)forgotPasswordForUser:(NSString *)user complete:(XBARequestCompletion)completion;
// Change password (with old / new password)
- (void)changePasswordFrom:(NSString *)oldPassword to:(NSString *)newPassword complete:(XBARequestCompletion)completion;
// save / load session, using for remember me function
- (void)saveSession;
- (void)loadSession;
还有一个非常好的消息,从现在开始,您可以使用XBAuthentication使用Facebook登录。只需以下简单步骤:
在AppDelegate文件中添加以下代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
return [[XBAuthentication sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];;
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[XBAuthentication sharedInstance] applicationDidBecomeActive:application];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [[XBAuthentication sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
请注意日志。它将提醒您在Info.plist中遗漏了哪些设置。只需按照要求填写所有信息。现在,当您准备好获取用户登录时,使用
[[XBAuthentication sharedInstance] startLoginFacebookWithCompletion:^(NSString *responseString, id object, int errorCode, NSString *description, NSError *error) {
... do anything that you want with responseString, object (response object), errorCode, description and error. all in your hand now.
}];
eugenenguyen, [email protected]
XBAuthentication可在MIT许可协议下使用。有关更多信息,请参阅LICENSE文件。