1

I would like to automatically test my application that sends push notifications.

I would like to be able to get (or generate) a token from Apple/Google for both Android and Apple devices that will be accepted by Apple's or Google's server and making the notification sent to my tester-program.

i.e, I am running my program (lets call it A) to test some server. The tests are relatively complex and involve a lot of network communication. I am testing the server as a black box, I cannot mock anything. I want to simulate a phone with program A that opens the client application and registers for push notifications. Then, I want to be able to see these notifications received on program A. Everything should be done in code, and not depended a real device.

Is this even possible? Does Apple/Google allow this type of test? I've read that the Android simulator is capable of receiving notifications as long as it has an active Google account on it, which is fine. Can this be simulated without the overhead of an Android simulator? Can it be done for Apple's iStuff ?

Mark Segal
  • 5,427
  • 4
  • 31
  • 69

1 Answers1

4

Push Notifications in Mavericks iOS Simulator: It seems you can use the iOS simulator to test push notifications, but I get it that you do not want to use a the simulator nor a device.

What you are asking for should not be allowed by Apple, as it means non-Apple devices would be allowed to register for push notifications. Per https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW12, "APNs generates a device token using information contained in the unique device certificate. The device token contains an identifier of the device. It then encrypts the device token with a token key and returns it to the device." Thus, in order to create the desired token, you need a unique device certificate -- in other words, a real device or iOS 8 simulator. If you are trying to test on a single "device," perhaps you could forge one or copy from a real device, but I am sure that is against Apple's policies.

Community
  • 1
  • 1
Josh Gafni
  • 2,831
  • 2
  • 19
  • 32
  • And what about Android? – Mark Segal Oct 28 '14 at 06:50
  • First off, to add to my previous answer, per https://cloud.google.com/developers/articles/ios-push-notifications/ you can push to iOS from Google Cloud, but it agrees with my answer that you need an actual iOS device. – Josh Gafni Oct 29 '14 at 16:15
  • Secondly, https://developer.android.com/google/gcm/gcm.html says that you can register for Google push with an Android device running Android 2.2 or higher that also have the Google Play Store application installed, or an emulator running Android 2.2 with Google APIs. It doesn't sound like the emulator counts as a "non-real" device. The part that you would need to copy or forge is the Registration_ID- "A registration ID is tied to a particular Android application running on a particular device." Again, probably against Google's policies. – Josh Gafni Oct 29 '14 at 16:21
  • What do you mean that I would need to forge the "Registration_ID"? What is that? Is it possible to get the specification for the protocol between the Android device and Google's servers so I could fake a phone? (I believe the simulator implements the exact same protocol as the actual phone) – Mark Segal Oct 30 '14 at 06:06
  • The form of the Registration_ID is not published. https://groups.google.com/forum/#!topic/android-c2dm/AUGlvmJPyMM shows a few guesses on the length of the ID. http://stackoverflow.com/questions/11324666/android-gcm-registration-id-max-length shows an example of the ID. The ID is used with a number of other credentials (see link from my previous comment) to ensure that all parties have been authenticated and that the push goes to the right place. The Registration_ID is used to identify the specific application on the specific device - so one piece of the process. – Josh Gafni Oct 31 '14 at 16:28
  • The push process is designed to prevent exactly this case. I don't think what you want is possible for an ordinary human :) - I'm sorry. – Josh Gafni Oct 31 '14 at 16:31