1

I've been searching everywhere (and experimenting) for the past week but i can't seem to find anything to point me in the right direction. I have the local version (https://github.com/onmyway133/PushNotifications/releases) running on my Mac and i am receiving notifications on my iPhone just fine (p8 and p12) but what i really need is to be able to send a push notification message from an iOS device.

It has to be possible since it is a simple HTTP/2 JSON outcall. I went through a lot of different libraries and samples for server-side implementation but can't find anything for Swift and iOS (i failed at compiling what i could find so far).

Any and all help and suggestions is greatly appreciated.

Grauhart
  • 21
  • 2
  • Could you take in cosideration adding firebase to your ios app? In this way you could use firebase rest api to send push notification directly from device with an http post call. Firebase makes the bridge between you and apple APNs servers. You nees only a server auth token from the firebase console and the fcm token of the device you wanna send the push to. If this could be a valid scenario, take a look at Firebase Cloud Messaging. – shadowsheep Dec 15 '18 at 00:39
  • I looked into Firebase and while there is a way to send "upstream" messages - i have not found a way for such messages to be automatically routed to specific devices. – Grauhart Dec 17 '18 at 00:54
  • If you are comfortable with @sateesh answer that’s a valid one too I would not going further on FCM. But you can send push notification from a device to another device through an http post request from the sending device (knowiing push token of the receiving device). Look here how to send push with http request https://stackoverflow.com/questions/38834020/sending-push-via-postman-using-firebase-messaging – shadowsheep Dec 17 '18 at 07:24

1 Answers1

0

Try NWPusher, where you can send push notifications not only from Mac OS X and from iOS as well.

https://github.com/noodlewerk/NWPusher

Push from iOS

The ultimate experience is of course pushing from an iPhone to an iPhone, directly. This can be done with the Pusher iOS app. Before you run the PusherTouch target, make sure to include the certificate, private key, and device token inside the app. Take the PKCS12 file that you exported earlier and include it in the PusherTouch bundle. Then go to NWAppDelegate.m in the Touch folder and configure pkcs12FileName, pkcs12Password, and deviceToken. Now run the PusherTouch target:

enter image description here

If everything is set up correctly, you only need to Connect and Push. Then you should receive the Testing.. push message on the device.

Sateesh Yemireddi
  • 4,289
  • 1
  • 20
  • 37
  • Thank you. NWPusher works well, i am able to send my messages from our iOS app, however... although the p12 is for both development and distribution - only "sandbox" mode works but "production" is returning an error (bad token). Is there something i am missing? – Grauhart Dec 17 '18 at 00:53
  • 1
    Have you been sending the messages to APNS production server ? – Sateesh Yemireddi Dec 17 '18 at 04:00
  • Yes, basically from what what information i gathered so far - it looks like APNs matches the "state" of the device to the environment. I may be wrong here but it looks like if the token was generated for a device that was in "test" mode (for example running a debug build through Xcode on an attached device) then that token can only be used in the sandbox environment and so on. If this is true then there is no issue and my app currently works as designed in respect to APNs connection, however - if someone can provide any documentation collaborating this speculation i would appreciate it. – Grauhart Dec 17 '18 at 23:33