title: iOS Push notifications using cordova. The notification is never received
body: <p>I created a sample Cordova app which is using "phonegap-push-plugin".
  That app doesn't have any complexity. On "deviceready" I run the plugin initialization code as shown here: </p>
  
  <pre><code>var push = PushNotification.init({android: {}, ios: {
  
      sound: true,
      alert: true,
      badge: true,
      categories: {
        invite: {
          yes: {
            callback: 'accept',
            title: 'Accept',
            foreground: true,
            destructive: false
          },
          no: {
            callback: 'reject',
            title: 'Reject',
            foreground: true,
            destructive: false
          },
          maybe: {
            callback: 'maybe',
            title: 'Maybe',
            foreground: true,
            destructive: false
          }
        },
        delete: {
          yes: {
            callback: 'doDelete',
            title: 'Delete',
            foreground: true,
            destructive: true
          },
          no: {
            callback: 'cancel',
            title: 'Cancel',
            foreground: true,
            destructive: false
          }
        }
      }
  }})
  
  push.on('notification', data =&gt; {
      console.log(data.message);
      console.log(data.title);
      console.log(data.count);
      console.log(data.sound);
      console.log(data.image);
      console.log(data.additionalData);
  })
  
  push.on('emailGuests', data =&gt; {
    console.log('I should email my guests');
  });
  
  push.on('snooze', data =&gt; {
    console.log('Remind me later');
  });
  
  push.on('registration',  data =&gt; {
    console.log(data.registrationId);
    console.log(data.registrationType);
  });
  
  push.subscribe('xx', console.log)
  </code></pre>
  
  <p>And this is the log output to console: </p>
  
  <pre><code>=&gt; Successfully subscribe to topic xx
  // The first run (after app install) will ask for permissions. If I click allow the lines below are printed to console.
  =&gt; dCAtjhCFBcU:APA91bG90c8VhNl_BzZ-2e9fmq_9fN6jfrRNJ1LPCRIpKnZ-AG-eLY4xtX84oJRZBh2D....KtNNQ35GM8ubPF5zr8HqeB6jffs
  =&gt; FCM
  </code></pre>
  
  <p>In order to push I'm sending the following payload to the Legacy Server <code>https://fcm.googleapis.com/fcm/send</code>.</p>
  
  <pre><code>{
      "priority": "high",
      "to": "/topics/xx", // I tried this but I also tried to specify the device token received upon "registration" event. I did this using to:&lt;device_token&gt; and also using registration_ids: [&lt;device_token&gt;].
      "notification": {
        "title": "My Message",
        "body": "My Message Body",
        "badge": 1,
        "content-available": "1", // I tried with and without
        "category": "identifier", // I tried with and without
        "thread-id": "id", // I tried with and without
        "sound": "default",
        "icon": "default"
      },
      "data": {
          "title": "A short string describing the purpose of the notification",
          "body": "The text of the alert message",
          "clubId": 1000
      },
      "notId": 1,
      "custom_key1": "value1",
      "custom_key2": "value2"
  }
  </code></pre>
  
  <p><strong>Note: I tried every combination possible in what concerns the app state:</strong> App in background; app closed; app in foreground; The event "notification" has never fired and the push notification was never received. </p>
  
  <p>The request sent to the FCM server returns a message id when I use the topic (which is understandable since other devices subscribe the topic). For that reason my android that has subscribed to the same topic receives the message. The iOS in the other hand receives nothing!</p>
  
  <pre><code>{
      "message_id": 5059997308576486332
  }
  </code></pre>
  
  <p>If I try to specify the token that I received upon registration, I will get a slightly different message. Most of the time the token received upon registration works and the results will contain a string id. But this is temporary since a few minutes later the token become "NotRegistered". </p>
  
  <pre><code>{
      "multicast_id": 88880398234xxxxx7,
      "success": 0,
      "failure": 1,
      "canonical_ids": 0,
      "results": [
          {
              "error": "NotRegistered" // &lt;-- This happens after a few minutes. I have to delete the app and reinstall it in order to get a new token.
          }
      ]
  }
  </code></pre>
  
  <p><strong>This is the build configuration</strong></p>
  
  <p><a href="https://i.stack.imgur.com/SRByT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SRByT.png" alt="ios background &amp; push"></a>
  <a href="https://i.stack.imgur.com/waPH7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/waPH7.png" alt="xx"></a></p>
  
  <p><strong>Notifications are correctly enabled on my iOS device. What am I missing?</strong> </p>
  
  <p><strong>Updated:</strong></p>
  
  <ul>
  <li>Accessing Apple's APN directly (yup... no FCM!)<br>
  I would like to send my push notifications through FCM but in order to determine the cause of the issues described above, I decided to try APN directly. To do this, I had to remove the  from the app's config.xml, so <code>phonegap-push-plugin</code> can obtain a token from APN and not from FCM.</li>
  </ul>
  
  <p>Now, using the new token and a server that uses <code>node-apn</code> module to communicate with APN server, I'm able to send push notifications to my iOS app. The downside of this, is that I lose the ability to push to topics since this is a <a href="https://github.com/phonegap/phonegap-plugin-push/issues/2612" rel="nofollow noreferrer">FCM only feature.</a></p>
  
  <p>The only thing that I still don't know is how to use the <code>topic</code> to target devices in the APN network, that are subscribed by the push.subscribe() method.</p>
  
  <p>Checkout my issue <a href="https://github.com/phonegap/phonegap-plugin-push/issues/2613" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Any help on this too? </p>