ios - iOS Shopify中的登录注册API实现

ios - iOS Shopify中的登录注册API实现,第1张

我正在使用shopify SDK开发移动应用程序,但是我无法找到任何实现登录/注册到我的应用程序的内容。我已经完成了购物车/产品但无法实现客户登录。是否有任何解决方案可以在应用程序中使用Shopify或我可以在shopify和自定义PHP服务之间创建的任何网桥实现登录/注册。

感谢。

最佳答案:

2 个答案:

答案 0 :(得分:0)

您可以使用来自API的Shopify的customer对象。

答案 1 :(得分:0)

您可以使用教程中给出的Shopify API,我已经为登录和注册提供了代码。

登录代码

 NSArray *credentialItems = @[
                             [BUYAccountCredentialItem itemWithEmail:self.txtEmailID.text],
                             [BUYAccountCredentialItem itemWithPassword:self.txtPassword.text],
                             ];
 BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:credentialItems];

[self.aClient loginCustomerWithCredentials:credentials callback:^(BUYCustomer * _Nullable customer, BUYCustomerToken * _Nullable token, NSError * _Nullable error) {

    if (customer && token && !error) {

        NSLog(@"Login Done");

    } else {
        //NSLog(@"Failed to login customer: %@", error.userInfo);
        _lblMessage.text=error.localizedDescription;
    }
}];

注册代码

NSArray *credentialItems = @[
                             [BUYAccountCredentialItem itemWithFirstName:self.txtFirstName.text],
                             [BUYAccountCredentialItem itemWithLastName:self.txtLastName.text],
                             [BUYAccountCredentialItem itemWithEmail:self.txtEmailID.text],
                             [BUYAccountCredentialItem itemWithPassword:self.txtPassword.text]
                             ];
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:credentialItems];

[client createCustomerWithCredentials:credentials callback:^(BUYCustomer * _Nullable customer, BUYCustomerToken * _Nullable token, NSError * _Nullable error) {

    if (customer && token && !error) {

        self.txtFirstName.text =@"";
        self.txtLastName.text = @"";
        self.txtEmailID.text=@"";
        self.txtPassword.text=@"";

        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Shopify" message:@"Signup successfully" preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
        [alertController addAction:okAction];
        [self presentViewController:alertController animated:YES completion:nil];
    }
    else
    {
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Shopify" message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
        [alertController addAction:okAction];
        [self presentViewController:alertController animated:YES completion:nil];

        //NSLog(@"Failed to create customer: %@", error.userInfo);
    }

    }];
本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复