Custom Notifications for your Mobile SDK Apps
Salesforce Mobile SDK enables developers to build custom mobile applications tailored to their specific business and UI needs. With the release of Salesforce Mobile SDK 8.2, you can now include custom notifications in your Mobile SDK applications. This has been a huge request from our customers who will now be able to leverage all the great aspects of the Salesforce Notification Builder feature.
The Salesforce Notification Builder feature has been a major hit with Salesforce admins everywhere. Admins can create custom notifications for a targeted audience, define when to trigger the notification, what message to display, and which users to notify. All with just a few clicks.
Until now, only users of desktop browsers and Salesforce-built mobile apps have been able to take advantage of these custom notifications. With the release of Salesforce Mobile SDK 8.2, custom notifications are available in your Mobile SDK-built applications.
If this is your first introduction to Salesforce Mobile SDK, learn more in the Mobile SDK trail.
- Leverage new and existing custom notifications in your Mobile SDK applications
- Leverage iOS and Android templates for a starter application that includes custom notifications
- Easily add custom notifications to your existing applications
- Notification types & triggers can all be packaged and distributed with your connected app
- Display notification list tray
- Display number of unread notifications
Learn about all the new features in Mobile SDK 8.2 in the Mobile SDK for iOS and Android release notes.
Mobile SDK and custom notifications
In order to use custom notifications with Mobile SDK, you’ll need to complete a few steps. You can find more information in the Notification Builder help pages and the Mobile SDK developers guide.
Setup custom notifications with Mobile SDK:
[Optional] Setup Mobile SDK for notifications list tray and unread count features
- Add custom UI code to your Mobile SDK app
- Call the push notification resource of the Connect REST API
You’ll notice that these are the same steps to setup standard push notifications with Mobile SDK. If you have already done that for your Mobile SDK apps and you’ve been previously using Notification Builder, there’s nothing left to do.
Creating a new app
If you’re just getting started with your Mobile SDK application, you can grab one of the following templates to get begin. The templates provide a starter application with push notifications. Simply add your business logic and custom UI, and you’re ready to go.
AndroidNativeKotlinTemplate which creates a starter application with push notifications for Android devices.
For 8.2, you can find push notifications in the
MobileSyncExplorerSwift and the
iOSEncryptedNotification templates. The MobileSyncExplorerSwift template includes push notifications and offline capabilities in your starter application. The iOSEncryptedNotification template includes an example extension to decrypt content before it is provided to the user. More details about this decryption are discussed later in this blog.
Adding custom notifications to an existing app
If you already have an existing Mobile SDK application and would like to add custom notifications, we’ve made it a simple process.
Android custom applications
If your existing Android application already supports push notifications, the app will be able to receive push notifications without any additional changes in the app. If you don’t already have push notifications setup, make sure to follow the steps in the Mobile SDK developer’s guide: About Push Notifications.
iOS custom applications
If your existing iOS application already supports push notifications, the app will be able to receive push notifications containing the title of the notification without any changes in the app. The body of the notification is encrypted. Apps will need to use a notification service app extension to decrypt the content before it’s provided to the user. Our encrypted notification template includes an example extension. Once the extension is in place, decrypting only takes one call to the SDK.
[SFSDKPushNotificationDecryption decryptNotificationContent:notificationContent error:nil];
Notification list tray feature
For iOS applications, the MobileSyncExplorerSwift template also includes endpoints to be able to display the notification list tray, so the user can see all the recent notifications that are marked as unread.
For Android & ReactNative applications, the endpoints are available to also show the notification list. We plan to include this in the Android & ReactNative templates in a future release.
Unread notifications indicator
For iOS applications, the MobileSyncExplorerSwift template also includes the ability to identify how many notifications are still unread by the user. In the starter app created by this template, you’ll see this appear as an icon with a number of unread notifications listed.
For Android & ReactNative applications, the endpoints are available to also show the unread list in your application. As above, we do plan to include this in the Android & ReactNative templates in a future release.
Mobile SDK provides developers complete control over the UI and business logic of their mobile applications. Custom notifications allow administrators to deliver just-in-time messages to users for important events. Now, you can build amazing custom mobile applications and keep your end-users in the know with all the same notifications available in the Salesforce mobile app.
About the Authors
Sue Berry is a Director of Product Management at Salesforce where she focuses on Salesforce Mobile. She’s currently working on Salesforce Mobile SDK and the new Mobile tools for LWC debugging. She has been building developer tools for over 15 years.
Brianna Birman is a lead engineer on Salesforce Mobile SDK and has worked on Salesforce Mobile products for the last seven years.