Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test FCM notification on iOS Simulator

Since Xcode 11, iOS simulators can now receive push notifications. This can be accomplished by executing a specific command or providing a JSON file to the simulator. I got this information from this blog: Test Notification on Simulator.

However, in my use case, I use Firebase Cloud Messaging to deliver notifications to the user of my app (Android and iOS both). I am unable to test the notification generated by Firebase on a simulator as the payload is different for FCM.

Is there a way to achieve this?
I found a similar question on the topic but there's no answer on it so far.

like image 645
Prerak Sola Avatar asked Sep 17 '20 16:09

Prerak Sola


1 Answers

For Testing push notifiction in simulator just creat a new file and paste following json object and save file in .apns , and then just drag and drop this file in simulator then push will work.

{
    "aps" : {
        "alert" : {
            "title" : "sarunw.com",
            "body" : "A asdfsadfsadf"
        },
        "badge" : 5
    },
    "Simulator Target Bundle": "bundleId"
}

For differenct payload just use following JSON object in Postman

{
 "to" : "ewebWDSSwYc:APA91bGOARO4eq9LlOfgfXPQZMK3IiRFanhzSSgkD6cVqJiPbnyuEgsvQMarDEl6Hg7_UMtFM6Hn90jyTsSENNqLNNLVjLSypR0voAO3j6orIsgabX-t0cpfJ0qpB2SzhZiXvor0r__d",
 "notification":
 {
    "title":"ABC",
    "body":"123",
    "mutable_content" : true,
    "category":"CustomSamplePush"
 },
 
 "data":
    {
        "sender_contact_code" : "+92",
     "sender_contact" : "(555) 564-8583",
     "group_name":"Testing Group",
     "type":"NewMessage",
     "type_id":"1213",
     "notification_type_id":"123213"
    }
}

with this url -> https://fcm.googleapis.com/fcm/send (Type will be POST)and in authorization you need to put Server key in Key Value, in that way you will be able to send push notification with your own formatted object.

also you can use Pusher for testing push notifiction & I have uploaded screenshot for reference.

postman_screenshot

like image 150
chanadboy Avatar answered Sep 28 '22 01:09

chanadboy