Update to version 3.4

This page explains how to update your SDK install to latest versions that may not require a breaking change. While these changes aren’t breaking—you don’t need to make these changes—they will simplify your integration, improve the reliability of your metrics, and improve deep link handling on iOS devices.

Upgrade from 3.3 to 3.4+

As of version 3.4, the Customer.io SDK automatically registers push device tokens to identified people and handles push clicks. These features simplify your SDK integration while improving compatibility with apps that use multiple push SDKs.

After you install a version of the SDK that is 3.4 or higher, follow these steps to upgrade.

 Do you have a swift app? Skip ahead!

If you’ve got a Swift app containing the AppDelegate.swift file, ignore the steps below and go to the Swift upgrade section.

  1. Open your push notification handler file (In our examples, we call this file MyAppPushNotificationsHandler.swift) and review all of the highlighted code below. We’ve highlighted the most relevant lines.

     import Foundation
     import CioMessagingPushAPN
     import UserNotifications // Delete this line
     import CioTracking
    
     @objc
     public class MyAppPushNotificationsHandler : NSObject {
    
         public override init() {}
         
         // Replace these 2 lines
         @objc(setupCustomerIOClickHandling:)
         public func setupCustomerIOClickHandling(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {    
         // With these 2 lines
         @objc(setupCustomerIOClickHandling)
         public func setupCustomerIOClickHandling() { 
             // This line of code is required in order for the Customer.io SDK to handle push notification click events. 
             // We are working on removing this requirement in a future release.
             // Remember to modify the siteId and apiKey with your own values.
             // let siteId = "YOUR SITE ID HERE"
             // let apiKey = "YOUR API KEY HERE"
             CustomerIO.initialize(siteId: siteId, apiKey: apiKey, region: Region.US) { config in
                 config.autoTrackDeviceAttributes = true
             }
    
             // Delete these 2 lines:
             let center  = UNUserNotificationCenter.current()
             center.delegate = notificationDelegate    
         }        
    
         // Delete this function: 
         @objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
         public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
             let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
             withCompletionHandler: completionHandler)
    
             // If the Customer.io SDK does not handle the push, it's up to you to handle it and call the
             // completion handler. If the SDK did handle it, it called the completion handler for you.
                 if !handled {
                 completionHandler()
                 }
             }
         }
     }
  2. Open your AppDelegate.h file and review all of the highlighted code below.

     #import <RCTAppDelegate.h>
     #import <UIKit/UIKit.h>
     #import <UserNotifications/UserNotifications.h> // Delete this line
    
     // Remove `UNUserNotificationCenterDelegate` from this line:
     @interface AppDelegate: RCTAppDelegate<UNUserNotificationCenterDelegate>
     // After this change, the line will look like this: 
     @interface AppDelegate: RCTAppDelegate
    
     @end
     #import <RCTAppDelegate.h>
     #import <UIKit/UIKit.h>
     #import <FirebaseMessaging/FIRMessaging.h>    
     #import <UserNotifications/UserNotifications.h> // Delete this line    
    
     // Remove `UNUserNotificationCenterDelegate` from this line:
     @interface AppDelegate: RCTAppDelegate<FIRMessagingDelegate, UNUserNotificationCenterDelegate>
     // After this change, the line will look like this: 
     @interface AppDelegate: RCTAppDelegate<FIRMessagingDelegate>
    
     @end
  3. Open your AppDelegate.m file and review all of the highlighted code below.

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         ...
         
         // Replace this line
         [pnHandlerObj setupCustomerIOClickHandling:self];
         // With this line: 
         [pnHandlerObj setupCustomerIOClickHandling];
    
         return YES;
     }
     
     - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
         // Remove the line below: 
         [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
     }
  4. Now that your app’s code has been simplified, follow the latest push notification setup documentation to enable these new features.

Upgrade from 3.3 to 3.4+, for Swift

  1. Open your AppDelegate.swift file and review all of the highlighted code below. We’ve highlighted the most relevant lines.

    import CioTracking
    import CioMessagingPushAPN
    
    class AppDelegate: NSObject, UIApplicationDelegate {
    
         func application(
             _ application: UIApplication,
             didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
         ) -> Bool {            
             CustomerIO.initialize(siteId: "YOUR SITE ID", apiKey: "YOUR API KEY", region: Region.US, configure: nil)
             
             // Delete this line
             UIApplication.shared.registerForRemoteNotifications()            
    
             return true
         }
      }
     
     // Delete this function 
     func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
         MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
     }
    
     // Delete this function 
     func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
         MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
     }
     
  2. Now that your app’s code has been simplified, it’s time to enable these new SDK features.

To do this, you’ll need to initialize the MessagingPush module. Follow the latest push notification setup documentation to learn how to do this.

Copied to clipboard!
  Contents
Current release
 3.7.1
Is this page helpful?