89

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

I want to know that can we receive push notification on iPhone Simulator or not. Also, I want something like this tell me if it is possible that, the app opens unregistered for push notification and when app terminates register for push notification.

Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256

1 Answers1

119

The iPhone Simulator is unable to receive push notifications or successfully register for them.

See the following: How can I test Apple Push Notification Service without an iPhone?

Community
  • 1
  • 1
Bryan Henry
  • 8,348
  • 3
  • 34
  • 30
  • 15
    In the XCode11.4 beta, they added the feature which allows testing push notification on the simulator. – Ahmed Ashraf Butt Feb 09 '20 at 17:16
  • 3
    Xcode 11.4 beta released with simulator to support remote push notifications: https://stackoverflow.com/a/60205613/905517 – MobileGeek Feb 13 '20 at 10:56
  • 3
    As of Xcode 11.4, you can start sending pushnotifications to the simulator using the command, xcrun simctl push more information here: https://ohmyswift.com/blog/2020/02/13/simulating-remote-push-notifications-in-a-simulator/ – Rizwan Ahmed Feb 15 '20 at 19:09
  • 2
    This is tutorial link for support Push notification in Simulator. https://medium.com/swlh/simulating-push-notifications-in-ios-simulator-9e5198bed4a4 – Hardik Vyas Feb 26 '20 at 11:38
  • 42
    FYI: Apple didn't added push notifications to simulator in Xcode 11.4, they added support for simulating push notifications. So this means that you cannot receive any push notifications, you can just simulate them. – wobsoriano Apr 20 '20 at 00:28
  • Since Xcode 12 it's possible to registrer to push and receive via the APNS payload. You can send a push like this : xcrun simctl push booted YOUR_BUNDLE payload.json booted = the current simulator payload.json is the APNS file on your Mac : { "Simulator Target Bundle": "xxx.xxx.xx ", "aps":{ "alert":{ "title":"XXX", "body":"YYY YYYY" }, "data":{ // stuff }, "mutable-content":1 } } – Medhi Dec 28 '20 at 14:20
  • https://medium.com/@lokesh.vyas4/ios-push-notification-from-terminal-to-app-d01019934758 – Lokesh Apr 21 '22 at 08:57
  • 2
    It’s finally possible! https://stackoverflow.com/a/73829063/1351469 – jcesarmobile Sep 23 '22 at 14:12
  • What about background push notifications (or silent notifications)? Can that be simulated? Background fetch and Background processing cannot be tested in simulator though. – NightFuryLxD Feb 14 '23 at 06:53