13

I have recently started iOS development, and was trying to build a simple web based iOS application with push notification feature using Firebase. I have tried about 3 tutorials about sending push notifications using FCM, including the one from official document, yet I could not receive any notifications from my iOS simulator. At this point, I am wondering if iOS simulator from xcode is not capable of receiving cloud messaging.

ps. I haven't tested with physical iOS device. (I don't have one yet)

IChung
  • 347
  • 1
  • 3
  • 8

2 Answers2

21

After Xcode 11.4 it is possible, but for firebase messaging it requires gcm.message_id value to be present. Otherwise it won't be handled by firebase SDK.

{
  "Simulator Target Bundle": "<your bundle>",
  "aps": {
    "badge": 0,
    "alert": {
      "title": "Test Push",
      "body": "Success! Push notification in simulator! ",
      "sound": "default"
    }
  },

  "gcm.message_id": "123",
  "example-data-key": "example-data-value"
}
Orkhan Alikhanov
  • 9,122
  • 3
  • 39
  • 60
  • 3
    `gcm.message_id` was not mentioned in any other answer. Adding that successfully triggered the Firebase messaging related callbacks. Thanks! – Slick Slime Mar 14 '22 at 07:52
8

Sorry to say, but you'll need to find some hardware to test this functionality.

Push notifications are not available in the simulator. They require a provisioning profile from iTunes Connect, and thus are required to be installed on a device. That also means you'll probably have to be accepted into the apple iPhone developer program and pay your $99.

How can I test Apple Push Notification Service without an iPhone?

abh
  • 1,189
  • 2
  • 14
  • 30
  • Thank you anyway! At least I don't have to waste any more time on finding a way to make it working – IChung Feb 04 '21 at 07:13
  • It might be possible in Xcode 11.4 version please see this answer https://stackoverflow.com/questions/1080556/how-can-i-test-apple-push-notification-service-without-an-iphone/60085404#60085404 – abh Feb 04 '21 at 07:54
  • 1
    I have seen that method from elsewhere, yet I cannot find a way to use it with Firebase. That feature seems like it is for testing how that app handles push notification. My current objective is to figure out if my firebase project can send message to my app, so it was no use for me ): – IChung Feb 04 '21 at 08:00