This help page is for users in Creator 5. If you are in the newer version (Creator 6), click here. Know your Creator version.

Configure push notification for your iOS app

As part of your Creator application’s workflows, you can configure push notifications. For these to work in your iOS app, you need to do the following. The instructions in this page assume that you have installed Creator's core framework or UI framework for the required type of mobile app (user or customer) - links are given in this section.

  1. Edit your Creator application.
  2. Navigate to your application's Settings by clicking the Settings at the top.
  3. Click Mobile SDK under Developer Tools.
  4. Click the For iOS button under the required section - For Users or For Customers. The For iOS pane will slide in from the right.
  5. Click the Configure button next to Push Notification. The Configure Push Notification for iOS app pop-up will appear.
  6. Upload your iOS app’s APNS p12 file by following the steps here.
  7. Enter your iOS app’s APNS p12 password.
  8. Enter your iOS app’s Bundle identified. For example: com.zylker.myapp
  9. Click Configure.
  10. In the XCode project, navigate to Project settings and choose your target.
  11. Select the Signing & Capabilities tab.
  12. Click +Capability tab.
  13. Select Push Notifications in the Capabilities pop-up window.

  14. Register your iOS app for remote notifications by calling registerForRemoteNotifications:
    Creator.configure(uiDelegate: self)
    
    UNUserNotificationCenter.current().delegate = self
    let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
    UNUserNotificationCenter.current().requestAuthorization(options: authOptions,completionHandler: {_, _in})
    UIApplication.shared.registerForRemoteNotifications()
  15. Register the device token with Zoho Creator's APNs server:
    Note: Upon registering for remote notification, the didRegisterForRemoteNotificationsWithDeviceToken method in AppDelegate provides the device token.
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
            ZCNotificationService.registerAPNS(deviceToken: deviceToken)
        }
  16. Enable the iOS device to receive notification by implementing the delegate method userNotificationCenter:center:willPresent:withCompletionhandler: and pass the options to the completion handler:
    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
      if let userInfo = notification.request.content.userInfo as? [String: Any] {
        print("is Creator Server : \(ZCNotificationService.isCreatorServerNotification(notificationInfo: userInfo))")
        // Change this to your preferred presentation option
      }
      completionHandler([[.badge, .alert, .sound]])
    }
        
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
      if let notificationInfo = response.notification.request.content.userInfo as? [String: Any] {
        if (ZCNotificationService.isCreatorServerNotification(notificationInfo: userInfo)) == true
        {
          if let zcnotification = ZCNotificationService.zcNotification(notificationInfo) {
          // We are showing the record summay as an example.
            let summaryVC = ZCUIService.getRecordSummaryViewController(for: zcnotification)
    window?.rootViewController?.present(UINavigationController.init(rootViewController: summaryVC), animated: true, completion: nil)
          }
        }
        else
        {
          // Not from Zoho Creator server
        }
        completionHandler()
      }
    }
  17. Unregister device from Zoho Creator's APNs server:
    Note: Unregistering a device requires authentication, so you must do it before the device logs out.
      ZCNotificationService.unRegisterAPNS {
      }
  18. Refer to the sample code snippets in this page.

To remove the push notification configuration

Note: Removing this configuration will cause your iOS app’s users to stop receiving push notifications that are triggered by the workflows in your Creator application.

  1. Click the trash icon next to Push Notification, as shown below.

  2. Click Remove to proceed.

Create an APNs p12 file

  1. Go to Keychain Access in your Mac.
  2. Click Keychain Access in the top menu bar.
  3. Select Certificate Assistant, then select Request a Certificate from a Certificate Authority:

  4. Enter your email address in the User Email Address field.
  5. Create a name for your private key in the Common Name field.

    Note: Leave the CA Email Address field empty.

  6. Select the Saved to disk option in the Request is group.
  7. Click Continue to complete the CSR generating process. The (.certSigningRequest) file will be saved on the desktop by default.
  8. Go to your Apple Developer's Account page.
  9. Navigate to the Certificates, IDs & Profiles page:

  10. Go to the Identifiers page.
  11. Select the App ID that you have created. You'll then get to edit your app ID configuration.
  12. Check the Push Notifications checkbox under the Capabilities section, then click Save:

  13. Click Create Certificate under the Production SSL Certificate section, then click Done:

  14. Click Continue.
  15. Upload the .certSigningRequest that you downloaded in step 7 of this section, then click Continue.
  16. Download the certificate and open it.
  17. Go to Keychain Access in your Mac.
  18. Select My certificates under Category in the bottom-left pane. The certificate you downloaded along with a private key will be available in the right pane.
  19. Control-click and select Export.
  20. Create a password for the file and remember the same for future use.
  21. Download the p12 file. This will be your iOS app's APNs p12 file.

Related topics

Still can't find what you're looking for?

Write to us: support@zohocreator.com