Registering your iOS app with Zoho generates a Client ID and Client Secret combination. These are required to allow your iOS app to integrate with your Creator application. To register your iOS app with Zoho:
#import <ZohoPortalAuthKit/ZohoPortalAuth.h>
import ZCCoreFramework
class
SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow ? func scene(
_scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) } let scope =
["aaaserver.profile.READ","zohocontacts.userphoto.READ","ZohoContacts.contactapi.READ","ZohoCreator.meta.CREATE","ZohoCreator.meta.READ","ZohoCreator.meta.UPDATE","ZohoCreator.meta.DELETE","ZohoCreator.data.CREATE","ZohoCreator.data.READ","ZohoCreator.data.UPDATE","ZohoCreator.data.DELETE","Stratus.stratusop.READ","ZohoCRM.modules.READ","ZohoCRM.users.READ"]let clientID =
"<Your Client ID>"let clientSecret =
"<Your Client Secret>"let portalId =
"<Your Portal ID>"let urlScheme =
"<Your Url Scheme>"let accountsUrl =
"https://accounts.zohoportal.com"// enter the accounts URL of your respective DC. For eg: EU users must use
'https://accounts.zohoportal.eu'ZohoPortalAuth.initWithClientID(clientID, clientSecret: clientSecret, portalID: portalId, scope: scope, urlScheme: urlScheme, mainWindow: self.window!, accountsPortalURL: accountsUrl) // To verify if the app is already logged in ZohoPortalAuth.getOauth2Token { (token, error) in if token ==
nil{ // Not logged in self.showLoginScreen() } else { // App logged in already. // Ensure to use the following line of code in your iOS app before you utilize any of Creator SDK’s methods Creator.configure(delegate: self) } } } func scene(
_scene: UIScene, openURLContexts URLContexts: Set <UIOpenURLContext> ) { if let context = URLContexts.first { let
_= ZohoPortalAuth.handleURL(context.url, sourceApplication: context.options.sourceApplication, annotation: context.options.annotation) } } } extension SceneDelegate: ZCCoreFrameworkDelegate { func oAuthToken(with completion: @escaping AccessTokenCompletion) { ZohoPortalAuth.getOauth2Token { (token, error) in completion(token, error) } } }
func showLoginScreen() { ZohoPortalAuth.presentZohoPortalSign( in: { (token, error) in if token !=
nil{ //login success } }) }
func logout() { ZohoPortalAuth.revokeAccessToken { (error) in if error ==
nil{ //Logout Successfully } else { //Error Occurred } } }
Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.
If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.
Write to us: support@zohoforms.com