Moves App SDK For iOS.
使用 CocoaPods
pod 'moves-ios-sdk', '~> 0.2.3'
钩子添加到 Podfile 中。pod install
,Moves SDK 将出现在项目中。手动方式,将 moves-ios-sdk 添加到项目中
当您将应用程序注册到 Moves 时,它将提供给您一个 Client ID 和 Client secret。它们用于标识您的应用程序对 Moves API 的访问。
将以下内容复制并粘贴到 Info.plist 的 XML 源中
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.yourcompany</string>
<key>CFBundleURLSchemes</key>
<array>
<string>[YOUR URL SCHEME]</string>
</array>
</dict>
</array>
[YOUR URL SCHEME] 在您 将应用程序注册到 Moves 时设置
在您的应用代理源文件的顶部(以及您调用 MovesAPI 对象的任何地方),您需要包含 MovesAPI.h
。只需添加此行:
#import "MovesAPI.h"
在 AppDelegate 中设置您的 [Client ID]、[Client Secret] 和 [Redirect URI]。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[MovesAPI sharedInstance] setShareMovesOauthClientId:@"[YOUR CLIENT ID]"
oauthClientSecret:@"[YOUR CLIENT SECRET]"
callbackUrlScheme:@"[YOUR URL SCHEME]"];
return YES;
}
给 SDK 准备好处理传入的 URL。
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
if ([[MovesAPI sharedInstance] canHandleOpenUrl:url]) {
return YES;
}
// Other 3rdParty Apps Handle Url Method...
return NO;
}
[[MovesAPI sharedInstance] authorizationWithViewController:self
success:^{
// Auth successed! Now you can get Moves's data
} failure:^(NSError *error) {
// Auth failed!
}];
获取用户资料
[[MovesAPI sharedInstance] getUserSuccess:^(MVUser *user) {
// Get user
} failure:^(NSError *error) {
// Something wrong
}];
更多其它 API 请参考 MovesAPI.h
文件
您可以克隆此仓库,并测试 API。
pod install
command
+ U
查看 MIT 许可证。