2
votes

I am currently using GCM to push notifications to both an iOS and Android version of my app.

With Android, I am able to process any message I send from the server client side, and then decide what I want to do with it. For example, I can receive a request, check client-side if the user has push notifications enabled, and THEN send a push notification from the client side.

The question is: Are there any client side methods of sending push notifications for iOS, similar to Android?

1

1 Answers

1
votes

To receive message, an iOS application needs to register with both Apple Push Notification service (APNs) and the GCM connection server. When a client app registers with GCM, it receives a registration token, which it must then send to the app server (the APNs device token is not sent to the server). The client app must store a boolean value indicating whether the registration token has been sent to the server.

You can follow this documentation on how to set up a client app on IOS.

Based on this SO question, It is very simple to implement APNs and GCM. You can follow this steps

  • When APNs (iOS Devices) and GCM (Android Device) registers for Push Notification on Apple and Google Server it generates a unique token for every device.

  • After that, you need to save that device token, with your device id or user id (unique id on your server for device) and the OS of device.

IOS device is sending this information on your server (backend) you can use this JSON format- {"token":"abcdedfgehik2bd3d3ff3sffssdff","os":"iOS","userid":34}

This is how it will work.

  1. You request device token from APNs as usual.
  2. You need to send that token to GCM service with provided API.
  3. Then GCM sends back a another token.
  4. Then send that token to app server.
  5. App server can send notifications using that token.

Try also to check this for more information.