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){// 參數(shù)個數(shù)可能有問題粮呢。 還好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.");
}
排版太難看,直接貼圖