No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Step 4. Using Apex Triggers to Send Push Notifications
Push notification triggers use methods in the Apex Messaging.PushNotification and Messaging.PushNotificationPayload classes. The connected app in the Salesforce organization represents the mobile client app that will receive the notifications.
Sample Apex Trigger
This sample Apex trigger sends push notifications to the connected app named Test_App, which corresponds to a mobile app on iOS mobile clients. The trigger fires after cases have been updated and sends the push notification to two users: the case owner and the user who last modified the case.
Sample Android Payload
The trigger sample uses Messaging.PushNotificationPayload to create a payload for an iOS notification. Unlike iOS, Android doesn’t have special attributes or requirements for the payload; it just needs to be in JSON format. In Apex, you create the Android payload as a MAP<String,ANY> object. The Messaging.PushNotification class handles conversion to JSON. Here is a sample Android payload.