iOS Shopify中的login/注册API实现

我正在开发一个使用shopify SDK的移动应用程序,但是我无法find任何东西来实现login/注册到我的应用程序。 我已经完成购物车/产品,但无法实现客户login。 有什么解决scheme来实现login/注册使用Shopify在应用程序或任何桥梁,我可以在shopify和自定义PHP服务之间创build。

谢谢。

您可以从API使用Shopify的客户对象。

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

代码login

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); } }];