You need to sign in to do that
Don't have an account?

Push Notifications: Invalid connected application
I'm at the beginning of configuring a Trigger for Push Notifications. I don't have a the mobile app yet (being built by another team member), so I'm mainly putting it together, getting test methods running, etc.
Here's my trigger:
I do have a Connected App setup, but it's essentially a placeholder. Is there something that I need to explicitly configure in the Connected App for the Push Notifications to not error out?
Here's my trigger:
trigger ObjectTrigger on Object__c (after insert) { for (Object__c m : Trigger.new) { Messaging.PushNotification msg = new Messaging.PushNotification(); Messaging.PushNotification androidMsg = new Messaging.PushNotification(); Map<String, Object> payload = Messaging.PushNotificationPayload.apple('New Message: ' + m.Subject__c , '', null, null); Map<String, Object> androidPayload = new Map<String, Object>(); androidPayload.put('subject', 'New Message: ' + m.Subject__c); // Adding the assembled payload to the notification msg.setPayload(payload); androidMsg.setPayload(androidPayload); // Adding recipient users to list Set<String> users = new Set<String>(); users.add(UserInfo.getUserId()); // Sending the notification to the specified app and users. // Here we specify the API name of the connected app. msg.send('Test_App', users); androidMsg.send('Test_App', users); } } }When running a test method against this, I get an error at the line: "msg.send('Test_App', users);", with the error being:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MessageTrigger: execution of AfterInsert caused by: System.NoAccessException: Invalid connected application: Test_App Class.Messaging.PushNotification.send: line 28, column 1 Trigger.MessageTrigger: line 22, column 1: []
I do have a Connected App setup, but it's essentially a placeholder. Is there something that I need to explicitly configure in the Connected App for the Push Notifications to not error out?
you are getting that error because on line 21 and 22 of your trigger class you have 'Test_App' and it should be the API name of your Connected App. So try switch 'Test_App' by something like 'Push_Notification_Test' (assuming that your Connected App is called Push Notification Test).
Let me know if this helps!
Question regarding this thread
What will be the name of the connected app, if I use Salesforce for Android connected app.
I am trying to send push notification to salesforce mobile app installed in my mobile. when a case is updated a notification is sent
Reply to the thread above:
Salesforce for Android and Salesforce for iOS API names are:
Chatter_for_Android
Chatter_for_iOS
you can find them from App Manager page. or query AppMenuItem table.
however, even after I switch to use the api name above, i still get the same error: Invalid connected application