iOS Push Notifications not working through GCM using Phonegap-plugin-push - ios

When using phonegap-plugin-push, we are creating a mobile application that uses GCM to send out push notifications to the mobile devices. We are able to push to Android devices correctly using GCM. The plugin gives us both the GCM and APNS registration tokens. When we use the GCM token to push to the APNS we are unable to push to the iOS device, however when we test the APNS token directly, we are able to push the notification. When using the GCM token and a test service we receive a "success" message, but no notification makes it to the device. We know that the device token is correct as we can send a notification directly using an online APNS push service. We have created all the certificates, we have development and production certificates.
As we receive a registration token from the GCM service using the device token and APNS token, I believe the problem lies within the communication between GCM and the device itself. As we are not receiving the notification to the device using GCM, but we are able to use the APNS token generated on registration to directly push to the device. The GCM with the registration token, will not push to device.
This link here describes the problem https://github.com/phonegap/phonegap-plugin-push/issues/532

There might be some problem with your provisional profile.
This tutorial might help you.
https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjr__OblLTNAhWHkpQKHT6MBUgQFggeMAA&url=https%3A%2F%2Fwww.raywenderlich.com%2F123862%2Fpush-notifications-tutorial&usg=AFQjCNFaM0baTw-x3Swz12MwCPu5XqEtLA&sig2=6wIOeDF8AvtCQfrheM2FXw

Related

Not Receiving Push Notifications on iOS using CapacitorJS and Ionic

Following the guide on Capacitor's site for push notifications, I am unable to receive any push notification inside my iOS device.
https://capacitorjs.com/docs/apis/push-notifications
I've triple checked that the Apple Push key and sandbox/production certificates are uploaded
I have successfully registered to the APNs and get a token value, but when I use Firebase to send a message to the token, I receive no notification.
I've also tried to send a message directly using this solution https://www.c-sharpcorner.com/UploadFile/pandeypradip/apple-push-notification-using-Asp-Net/ and I can send the message successfully, but I receive no response at all.
My app capabilities:

Difference between using Certificate based APN service VS Device Token APN service

I'm a little confused on the difference between using Certificate based connections to the APN service verse the Device Token method.
My understanding is, when sending a push notification to an iOS device, my options are either:
A) I could have registered the APN certificate with the Application bundle, and my provider can send it to the APN service to verify I'm allowed to send notifications to devices with that Application bundle.
B) My provider could be sent a "Device Token" via the downloaded application on the device over HTTP, and when I send that Device Token to the APN service, it will know the user has allowed me to send those notifications.
My questions are:
1) If I were to use method A, how could I target certain devices to send the notifications to if I don't have a device token?
2) If I use method B, where would I receive the device token to send silent notifications if my user "Doesn't Allow" push notifications? Will
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
Still run and allow me to pull the deviceToken out, so I can send it via HTTP to my provider?
I've adopted a piece of software that used Certificate based Push Notifications (I think) and was unsure of how it was differentiating who to send notifications to with any deviceTokens. Once I rebuilt and redownloaded the application on my iOS device the notifications stopped working, so I assumed the certificate was no longer associated with the build.
I'm also curious as to how someone can debug notifications on a physical device. I've tried the Console app on Mac and have had little luck seeing any print statements I put in the code.
I'm still very new to iOS programming so please correct me if any of my understanding of the APN Service is wrong! Thank you very much in advance!
There are a few things to understand:
Your Company/Team's Certificate
Your App/Bundle's Provisioning profile
Your Client/User's Device Token
Your BackEnd Server
1 & 2 are bundled in your app when you upload it to App Store.
You get 3 when you ask user the permission for sending PN. [For this 2 should have the capability for remote push notifications enabled]
You give 1 & 3 to 4. [1 for establishing connection with APNS server, 3 to send PN to a specific iOS device]
So, to answer your question: You need both A & B.
For better understanding how APNS works I am attaching a reference diagram that would help to clear your concept for the same.
** If I were to use method A, how could I target certain devices to send the notifications to if I don't have a device token?**
Without Device token, you won't be able to target the iPhones or
idevices on which you want to send the push notification
if my user "Doesn't Allow" push notifications -> then you won't be able to generate PUSH DEVICE TOKEN hence in this scenario you won't be able to receive any push notification.

Sending push notification without configuring APNs authentication key

In official firebase documentation it is said that
For FCM specifically, you'll need to upload your APNs authentication key and register for remote notifications.
https://firebase.google.com/docs/cloud-messaging/ios/client
Is it possible to send push notification without configuring a APNs authentication key in firebase console?
If it is not possible then why?
It's not possible, since the APNs says it in the very name, Push Notification Services, if you don't configure that then you'll be sending your notifications to nothing, I understand that's how your project will know were it's receiving the notifications from, so it can process them and sending to your app.

Will new APNS certificate invalidate previous auth key - iOS?

I am using APNS auth key for push notification in my iOS app which directs notification via Firebase cloud messaging. App is live on appstore and notifications are working fine. However, I have to integrate a chat SDK which requires APNS certificate for push notification for that app. I haven't created any APNS cert yet. My doubt is if I create a new APNS certificate, will it invalidate my previous APNS auth key? I dont want live users to stop receiving notifications.

send notification like push notification without APNS server in ios,

I want to send push notification without any APNS server and device token,like android there is NO local and push notifications but they can send device to device with out google permissions.
You can NOT send a push notification without using APNs. Why? first you need to understand how the technology works:
You need a certificate for a handshake.
You need a device token to be identified by APNs.
In your app, you have to register to APNs.
The app requests the certificate from APNs (handshake).
The server sends back its certificate.
The app will establish a connection to the server and send the PN certificate to the APN server.
The server will validate that you are a trusted app.
The app requests to create a token.
The server creates a token and sends it back.
In your app you save the token (to do e.g. push notifications to a specific user instead of a broadcast).
End.
So, as you see, you need to establish a trusted connection, the APNs is responsible for creating a token to identify your device within the network, and will be responsible for sending notifications.
For more info you could see:
Apple PNs

Resources