調用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.");

}

排版太難看,直接貼圖

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容