Update from 2.10 to 2.11
UpdatedThere's a new version available!
These pages cover version 2 of our SDK, but a newer version is available. In general, we suggest that you update to the latest version to take advantage of new features and fixes.
- Are you new to our SDKs? Check out the latest docs.
- Otherwise, learn about updating to the latest version
This page explains how to update to version 2.11 of our native iOS SDK. While these changes aren’t breaking—you don’t have to implement these changes—they will simplify your integration, improve the reliability of your metrics, and improve deep link handling. Updating your integration also sets you up for success in future releases.
Upgrade from 2.10 to 2.11+
As of version 2.11, the Customer.io SDK automatically registers push device tokens to identified people and automatically handles push clicks. These features let you simplify your SDK integration while also improving the reliability of device tokens and opened
metrics.
After you install version 2.11
or later:
Open your
AppDelegate
file and review the highlighted code in the sample below. You can remove all of the highlighted code from your app. You might need to leave some of these lines in your app depending on your app’s configuration. See comments in the code sample to determine whether you should delete the code or not.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") // Do not delete line if: you use push device tokens for more then Customer.io UIApplication.shared.registerForRemoteNotifications() // Do not delete line if: your app receives push notifications from services other then Customer.io. // Or, you display local notifications and you need to handle them getting clicked. UNUserNotificationCenter.current().delegate = self return true } // If you deleted the line, `UIApplication.shared.registerForRemoteNotifications()`, you can delete this function. func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) } // If you deleted the line, `UIApplication.shared.registerForRemoteNotifications()`, you can delete this function. func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error) } } // If you deleted the line, `UNUserNotificationCenter.current().delegate = self`, you can delete this `extension` block. extension AppDelegate: UNUserNotificationCenterDelegate { func userNotificationCenter( _ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void ) { // Send Customer.io SDK click event to process. This enables features such as // push metrics and deep links. 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() } } @available(iOS 10.0, *) func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void ) { completionHandler([.list, .banner, .badge, .sound]) } }
import CioMessagingPushFCM import CioTracking class AppDelegate: NSObject, UIApplicationDelegate { func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil ) -> Bool { FirebaseApp.configure() CustomerIO.initialize(siteId: "YOUR SITE ID", apiKey: "YOUR API KEY") // Do not delete these 2 lines if: you use push device tokens for more then Customer.io Messaging.messaging().delegate = self UIApplication.shared.registerForRemoteNotifications() // Do not delete line if: your app receives push notifications from services other then Customer.io. // Or, you display local notifications and you need to handle them getting clicked. UNUserNotificationCenter.current().delegate = self return true } } // If you deleted the line, `Messaging.messaging().delegate = self`, you can delete this `extension` block. extension AppDelegate: MessagingDelegate { func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { MessagingPush.shared.messaging(messaging, didReceiveRegistrationToken: fcmToken) } } // If you deleted the line, `UNUserNotificationCenter.current().delegate = self`, you can delete this `extension` block. extension AppDelegate: UNUserNotificationCenterDelegate { func userNotificationCenter( _ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void ) { // Send Customer.io SDK click event to process. This enables features such as // push metrics and deep links. 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() } } @available(iOS 10.0, *) func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void ) { completionHandler([.list, .banner, .badge, .sound]) } }
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.