Newer Version Available
Enable Push Notifications in a Salesforce Mobile SDK iOS App
Salesforce Mobile SDK for iOS provides the SFPushNotificationManager class to handle push registration. To use it, import <SalesforceSDKCore/SFPushNotificationManager>. The SFPushNotificationManager class is available as a runtime singleton:
This class implements four registration methods:
Mobile SDK calls registerForSalesforceNotifications after login and unregisterSalesforceNotifications at logout. You call the other two methods from your AppDelegate class.
-
Register with Apple for push notifications by calling registerForRemoteNotifications. Place
the call in the application:didFinishLaunchingWithOptions: method.
If registration succeeds, Apple passes a device token to the application:didRegisterForRemoteNotificationsWithDeviceToken: method of your AppDelegate class.
-
Forward the device token from Apple to SFPushNotificationManager by calling didRegisterForRemoteNotificationsWithDeviceToken on the SFPushNotificationManager shared instance.
-
Register to receive Salesforce notifications through the connected app by calling registerForSalesforceNotifications. Make
this call only if the access token for the current session is valid.
-
Add the following method to log an error if registration
with Apple fails.