调用StoreService函数登陆iTunesStore

typedef void(^CallbackBlock)(NSString* resp);

-(void) signIn: (NSString*) username password:(NSString*)password callback: (CallbackBlock) callback {

    NSLog(@"check Account: %@, %@", username, password);

SSAccountStore* accountStore =  [SSAccountStore defaultStore];

NSArray* accountTable = [accountStore accounts];

NSLog(@"account cache count %d",(int)accountTable.count);

for (SSAccount* account in accountTable){

NSLog(@"account name %@\n", [account accountName]);

}

[accountStore signOutAllAccounts];

SSAuthenticateRequest *req = [SSAuthenticateRequest alloc];

NSLog(@"allocate request ok\n");

SSMutableAuthenticationContext *context = [SSMutableAuthenticationContext  contextForSignIn];

NSLog(@"get context for signin ok");

SSAccount * account = [SSAccount alloc];

[account setAccountName: username];

[context initWithAccount: account];

[context setInitialPassword: password];

NSLog(@"set account ok");

NSLog(@"%@", req.delegate);

[req initWithAuthenticationContext:context];

NSLog(@"init authentication ok");

typedef void(^Block)(SSAuthenticateResponse* response1);

Block block = ^(SSAuthenticateResponse* authResponse){// 参数个数可能有问题。 还好arm64 是寄存器传参。

NSLog(@"login response callback here %@", authResponse);

NSLog(@"callback authResponseType %d", [authResponse authenticateResponseType]);

SSAccount * account = [authResponse authenticatedAccount];

NSLog(@"callback authResponse accountName %@ isActive %d isAuthed %d",

[account accountName], [account isActive], [account isAuthenticated]);

NSLog(@"callback authResponse firstName %@ lastName %@ ITunesPassSerialNumber %@ creditsString[卡上多少钱] %@ ",

[account firstName], [account lastName], [account ITunesPassSerialNumber], [account creditsString]);

NSLog(@"callback authResponse isNewCustomer %d secureToken %@ uniqueIdentifier[appleID 编号] %@",

[account isNewCustomer], [account secureToken], [account uniqueIdentifier]);

//

if ([authResponse authenticateResponseType] != 0) {

if (callback != nil)

callback(@"ok");

} else {

if (callback != nil)

callback(@"fail");

}

};

[req startWithAuthenticateResponseBlock:block];

NSLog(@"start authentication finish... block call back I dont known.");

}

排版太难看,直接贴图

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容