How to test Mobile app push notification capabilities in an emulator?
Asked Answered
S

2

13

Is it possible to test push notification in mobile apps, such as android & ios, with an emulator rather than a physical device?

In this ( http://docs.telerik.com/platform/appbuilder/sample-apps/sample-backend-services-pushnotifications ) article, I learned that such testing was not possible from within the emulator. During a quick Google search, I noticed many other push-notification services couldn't be tested in the emulator.

I would like to be able to be able to test the push-notification feature without needing to posses a physical device, because I can't afford them.

Shortwinded answered 3/3, 2014 at 20:42 Comment(1)
Seems parse does support push notifications to emulators parse.com/tutorials/android-push-notificationsBouldin
B
9

iOS

You cannot test real push notifications on iOS Simulator because it does not support it. You would get this error if you tried to register for remote notifications:

NSCocoaErrorDomain Code=3010 "Remote notifications are not supported in the simulator"

You should try to debug the app on real device not on the simulator. However you can mock push notifications on iOS using this library.

Android

The Android emulator is capable of receiving push notifications through GCM, however, it does require an additional step of actually logging a valid Google account into the emulator when it is running. This will need to be done for each emulator that you wish to use with push notifications through GCM.

Blake answered 3/3, 2014 at 21:47 Comment(4)
What do I need to do to log into a Google account in the emulator? On the emulator, under settings, I see an option for "accounts," but this appears to be e-mail only because the choice is between IMAP and Exchange.Lookthrough
You probably need to use a Google APIs target when you create your AVD.Yvor
IOS now allows test push notifications on Simulators from xcode 11.4 upwords developer.apple.com/documentation/xcode-release-notes/…Saintpierre
I believe also Google Play app is needed, and it isn't always available. I installed Google APIs and no Google Play, now download the one which has Google Play specified (not available for all devices)Eatton
W
2

Just in case anyone runs across this post (it was a top hit for me searching for similar information) looking to do this in a more modern (than 2014) Xcode environment: YES, it is possible to do this in iOS simulator now! This page has a great tutorial on how to do so.

Quick summary: create a JSON-formatted text file containing the payload, such as

{
  "Simulator Target Bundle" : "com.example.app",
  "aps" : {
    "alert" : {
        "title" : "push title",
        "body" : "push body"
    }
  },
  "isRead" : false,
  "createdOn" : "2021-12-01T20:14:50.3157643+00:00",
}

then drag and drop that file onto the simulator!

Weintrob answered 3/12, 2021 at 19:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.