• Miguel Duarte
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi,
I am still stuck on this FSL module with the error messagescreenshot Could not find a completed Service Appointment with the Description of 'Drill'.
Please can someone help me get to the bottom of this as I now have to complete this module as pre-reqs for FSL training next week.
Thank you
Matt
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:
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?