Newer Version Available
Build Your Own In-App Notification Feature
- Notification
- Get a specific notification for the context user.
- Notifications
- Get notifications for the context user.
- Notifications Status
- Get the “read” and “seen” properties a range of notifications.
- Notification Update
- Update the “read” and “seen” properties of a specific notification.
- Notifications Update
- Update the “read” and “seen” properties of a range of notifications.
- Display a list of notifications (Notifications)
- When the customer taps a list entry, display the details of a single notification (Notification)
- Set the state of a widget that indicates whether a notification has been read or seen (Notification)
- Report how many notifications the customer hasn’t read or seen (Notifications Status)
- Update the “read” or “seen” properties on one or more notifications after the customer visits your tray (Notification Update, Notifications Update)
Custom In-App Notification Tray Template App
- Install the latest forceios version from
node.js:
1[sudo] npm install -g forceios - Call the forceios createWithTemplate
command:
1forceios createWithTemplate - At the first prompt, enter
MobileSyncExplorerSwift:
1forceios createWithTemplate 2Enter URI of repo containing template application or a Mobile SDK template name: 3 MobileSyncExplorerSwift - In the remaining prompts, enter your company and project information. If your information is accepted, forceios creates a project with a notifications tray that you can customize.
- If you’re updating an older Mobile SDK project, copy your app-specific resources from your old project into the new project.
See the Reference section for more information on Notification APIs.
Mobile SDK iOS Wrappers for Notification APIs
- Swift
-
1RestClient - Objective-C
-
1SFRestApi
Notification
Get a notification.
- Swift
-
1RestClient.shared.request(forNotification:apiVersion:) - Objective-C
-
1- (SFRestRequest *)requestForNotification:(NSString *)notificationId apiVersion:(NSString *)apiVersion;
Block Method
Not available.
Notifications Status
Get the status of a range of notifications, including unread and unseen count.
- Swift
-
1RestClient.shared.request(forNotificationsStatus:) - Objective-C
-
1- (SFRestRequest *)requestForNotificationsStatus:(NSString *)apiVersion;
Block Method
Not available.
Notifications
Get the given number (maximum 20) of archived Notification Builder notifications based on the given “before” or “after�� date. In Mobile SDK, use the Swift FetchNotificationsRequestBuilder object or the Objective-C SFSDKFetchNotificationsRequestBuilder to create GET requests for notifications.
- Swift
-
1let builder = FetchNotificationsRequestBuilder.init() 2builder.setSize(10) 3builder.setBefore(Date.init()) 4let request = builder.buildFetchNotificationsRequest(SFRestDefaultAPIVersion) - Objective-C
-
1SFSDKFetchNotificationsRequestBuilder *builder = 2 [[SFSDKFetchNotificationsRequestBuilder alloc] init]; 3[builder setBefore: [NSDate date]]; 4[builder setSize:10]; 5SFRestRequest *fetchRequest = 6 [builder buildFetchNotificationsRequest:kSFRestDefaultAPIVersion];
Block Method
Not available.
Notifications Update
Update the “read” and “seen” statuses of a given set of Notification Builder notifications. In Mobile SDK, use the Swift UpdateNotificationsRequestBuilder object or the Objective-C SFSDKUpdateNotificationsRequestBuilder object to create update requests.
To update a single notification, set the notificationId property. To update a range of notifications, set either the notificationIds or the before property. These properties—notificationId, notificationIds, and before—are mutually exclusive.
- Swift
-
1let builder = UpdateNotificationsRequestBuilder.init() 2builder.setBefore(Date.init()) 3builder.setRead(true) 4builder.setSeen(true) 5let request = builder.buildUpdateNotificationsRequest(SFRestDefaultAPIVersion) - Objective-C
-
1SFSDKUpdateNotificationsRequestBuilder *builder = 2 [[SFSDKUpdateNotificationsRequestBuilder alloc] init]; 3[builder setRead:true]; 4[builder setSeen:true]; 5[builder setBefore: [NSDate date]]; 6SFRestRequest *updateRequest = [builder buildUpdateNotificationsRequest:kSFRestDefaultAPIVersion];
Block Method
Not available.
Mobile SDK Android Wrappers for Notification APIs
On Android, the RestRequest class defines the following convenience wrappers for Notification APIs.
Notification
Get a notification.
1public static RestRequest getRequestForNotification(String apiVersion,
2 String notificationId)Notification Update
Update the “read” and “seen” statuses of a given Notification Builder notification.
1public static RestRequest getRequestForNotificationUpdate(String apiVersion,
2 String notificationId, Boolean read, Boolean seen)Notifications
Get the given number (maximum 20) of archived Notification Builder notifications based on the given “before” or “after” date.
1public static RestRequest getRequestForNotifications(String apiVersion,
2 Integer size, Date before, Date after)Notifications Status
Get the status of a range of notifications, including unread and unseen count.
1public static RestRequest getRequestForNotificationsStatus(String apiVersion)Notifications Update
Update the “read” and “seen” statuses of a given set of Notification Builder notifications.
1* public static RestRequest getRequestForNotificationsUpdate(String apiVersion,
2 List<String> notificationIds, Date before, Boolean read, Boolean seen)