function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Surendra MandipalleSurendra Mandipalle 

Can we send push notification to custom mobile app users(non salesforce users) from Salesforce?

Hi,

We have an app developed on iOS, and our customers will login to that app. the app is integrated with Salesforce. Now I want to send a push notification based on the real time changes to customer records in salesforce.

Steps I followed:
Integrated the mobile app with Salesforce.
Created a connected app, and enabled push notifications.
Saved the devike token in salesforce for each mobile user (non- Salesforce).

Tested the configuration with "Send test notification" option on connected app by providing the device token as recipient, it worked fine.
User-added image


I tried creating a trigged to send notification, here is the sample code:

Messaging.PushNotification msg =new Messaging.PushNotification();
        Map<String, Object> payload =Messaging.PushNotificationPayload.apple('data has been changed', ' ', 0 );
        msg.setPayload(payload);     
        set<string> receipient=new set<string>();
        receipient.add('005g00000057P5v');
        msg.send('appname', receipient);

In the msg.send method we have to provide connected app name and list of user(salesforce).
But, i want to send the push notification to non salesforce users based on their device token which is generated by APNC and its stored in Salesforce.

Is there any other method to send the push notification based on their device token. Please let me know if my question is not clear.

Please provide some ideas or sample code to handle this situation.

Thanks in advance.
Edgar MoranEdgar Moran
You can send push notification to external users always you have stores the Push Key (Android or IOS) in you Standard or Custom object, but in this case for Android devices should be easy with an HTTP request to GMC, for IOS I suspect maybe you need an intermediate app (Heroku / PHP (laravel or symphony) ) hosted externally to send the push to Apple thinking about the certificates and pem files. The push notification in connected apps should work sending push just when users are part of the pull of Salesforce users. It's my understanding, but maybe something has changed in the last releases.

Best
Surendra MandipalleSurendra Mandipalle
Thanks for the reply, connected app has option to upload certificate for iOS, and tested the notification with device token as recepient on connected app. It worked. Now i wanted to know, how to send push notifications usig APEX with deive token as recepient.