看雪论坛
发新帖

[原创]iOS 调用storeService函数登陆iTunes

ppbb 2017-9-8 11:24 212
-(void) checkAccount: (NSString*) username password:(NSString*)password callback: (CallbackBlock) callback {
    NSLog(@"check Account: %@, %@", username, password);

    // 开始验证
    SSAuthenticateRequest *req = [SSAuthenticateRequest alloc];
    SSMutableAuthenticationContext *context = [SSMutableAuthenticationContext  contextForSignIn];
    SSAccount * account = [SSAccount alloc];
    [account setAccountName: username];
    id unk1 = [context initWithAccount: account];
    [context setInitialPassword: password]; //password为明文密码.
    unk1 = [req initWithAuthenticationContext:context];
    NSLog(@"init authentication ok");
    typedef void(^Block)(SSAuthenticateResponse* response1);
    
    Block block = ^(SSAuthenticateResponse* authResponse){
        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) {
            //callback(@"ok");
            NSLog(@"sucess");
            //[[SocketHelper shareInstance] emit:@"msgPushLoginAppAccountFinish" dicDatas:@{@"state":@"success"}];
        } else {
            //callback(@"fail");
            NSLog(@"fail");
            //[[SocketHelper shareInstance] emit:@"msgPushLoginAppAccountFinish" dicDatas:@{@"state":@"fail"}];
        }
        // 登陆成功后获取到的数据如下。
        //AppStore[1935] <Warning>: login response callback here <SSAuthenticateResponse: 0x1477f93c0>
        //AppStore[1935] <Warning>: callback authResponseType 3
        //AppStore[1935] <Warning>: callback authResponse accountName ppbb@pediy.com isActive 1 isAuthed 0
        //AppStore[1935] <Warning>: callback authResponse firstName ppbb lastName pediy ITunesPassSerialNumber (null) creditsString[卡上多少钱] ¥5.00
        //AppStore[1935] <Warning>: callback authResponse isNewCustomer 0 secureToken (null) uniqueIdentifier[appleID 编号] 0xbadbad
        
    };
    [req startWithAuthenticateResponseBlock:block]; // req 这个类里面有个delegate 是接收服务器返回的消息的。
    NSLog(@"start authentication finish... block call back I dont known.");
}
本主题帖已收到 0 次赞赏,累计¥0.00
最新回复 (3)
Diabloking 2017-9-8 13:10
2
datas
qqsunqiang 2017-9-8 15:00
3
datas,数据什么啊。
ppbb 2017-9-8 15:29
4
qqsunqiang datas,数据什么啊。
那个与验证无关。  是其模块的代码。  不影响login
返回



©2000-2017 看雪学院 | Based on Xiuno BBS | 域名 加速乐 保护 | SSL证书 又拍云 提供 | 微信公众号:ikanxue
Time: 0.013, SQL: 9 / 京ICP备10040895号-17