title: Cordova-Plugin-Firebase, iOS: device receives push notification but does not appear on device
body: <p>Testing Cordova Firebase plugin: working on Android; iOS, no such luck...</p>
  
  <p>I've created the necessary Ids, Certificates and private keys in my Developer account and on my Mac and set-up the "iOS" app in the Firebase Console.
  FYI: In the Cloud Messaging config in Firebase I am using the APN Auth Key method and not a dev certificate as Firebase indicates a preference for the Auth Key method.</p>
  
  <p>So I have created a new Cordova app - imaginatively called "pushnotificationsdemo", here are the steps I have used to create the App, configure the FCM and test it:</p>
  
  <p>Create a Cordova app using Firebase plugin:</p>
  
  <pre><code>cordova —version
  </code></pre>
  
  <p>8.1.2 (cordova-lib@8.1.1)</p>
  
  <pre><code>cordova pushnotificationsdemo com.XXX.pushnotifications.com “Push Notifications Demo”
  cd push*
  cordova plugin add cordova-plugin-firebase
  </code></pre>
  
  <p>[copy the “GoogleService-Info.plist” downloaded from the Firebase Console into the new Cordova project's root folder]</p>
  
  <pre><code>cordova platform add ios
  </code></pre>
  
  <hr>
  
  <p>*Using cordova-fetch for cordova-ios@~4.5.4</p>
  
  <p>Adding ios project...</p>
  
  <p>Creating Cordova project for the iOS platform:</p>
  
  <p>Path: platforms/ios</p>
  
  <p>Package: com.foliagos.pushnotificationsdemo</p>
  
  <p>Name: Push Notifications Demo</p>
  
  <p>iOS project created with cordova-ios@4.5.5</p>
  
  <p>Installing "cordova-plugin-firebase" for ios</p>
  
  <p>Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project</p>
  
  <p>Installing "cordova-plugin-whitelist" for ios</p>
  
  <p>Adding cordova-plugin-whitelist to package.json</p>
  
  <p>Saved plugin info for "cordova-plugin-whitelist" to config.xml</p>
  
  <p>Preparing Firebase on iOS</p>
  
  <p>--save flag or autosave detected</p>
  
  <p>Saving ios@~4.5.5 into config.xml file ...*</p>
  
  <hr>
  
  <p>Open iOS project in Xcode (<em>version 10.1</em>):</p>
  
  <ul>
  <li>Set Signing Team in “General” (to stop the Code 65 error when I attempt to build the app using the Cordova command-line)</li>
  </ul>
  
  <p>I am using Xcode10, so while I am there I also set the build type to the “legacy” system (because Cordova 8.1.2 is not compatible with the new build system):</p>
  
  <ul>
  <li><p>File | Workspace Settings</p></li>
  <li><p>Build System: "Legacy Build System"</p></li>
  </ul>
  
  <p>And because I want to see a lot of debugging output I also set this in Xcode:</p>
  
  <ul>
  <li>Product | Scheme | Edit Scheme | tab: Arguments —> Arguments Passed On Launch, add this: “-FIRAnalyticsDebugEnabled”</li>
  </ul>
  
  <p>And added the following into the “Push Notifications Demo-Info.plist” file in the “Resources” project folder:</p>
  
  <ul>
  <li><p>“UIBackgroundModes”</p></li>
  <li><p>with the following key: “remote-notification”</p></li>
  </ul>
  
  <p>I also added in the following preference into Cordova’s config.xml to turn off Cloud backup:</p>
  
  <pre><code>&lt;preferencename="BackupWebStorage"value="none"/&gt;
  </code></pre>
  
  <p>Now I build the new Cordova app from the command-line (using the legacy build system):</p>
  
  <pre><code>cordova build ios --buildFlag='-UseModernBuildSystem=0'
  </code></pre>
  
  <p>The archive is built successfully!</p>
  
  <p>Back in Xcode, I build the app and the following is written to the Console:</p>
  
  <hr>
  
  <p>Nov  8 17:50:54  Push Notifications Demo[414] :  - [I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist</p>
  
  <p>2018-11-08 17:50:54.312 Push Notifications Demo[414:66091] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/8AC0457B-0792-4A8F-8FFA-25655DB5DD8A/Library/Cookies/Cookies.binarycookies</p>
  
  <p>2018-11-08 17:50:54.558 Push Notifications Demo[414:66091] Apache Cordova native platform version 4.5.5 is starting.</p>
  
  <p>2018-11-08 17:50:54.558 Push Notifications Demo[414:66091] Multi-tasking -> Device: YES, App: YES</p>
  
  <p>2018-11-08 17:50:54.691 Push Notifications Demo[414:66091] Using UIWebView</p>
  
  <p>2018-11-08 17:50:54.697 Push Notifications Demo[414:66091] [CDVTimer][console] 0.401020ms</p>
  
  <p>2018-11-08 17:50:54.698 Push Notifications Demo[414:66091] [CDVTimer][handleopenurl] 0.479937ms</p>
  
  <p>2018-11-08 17:50:54.707 Push Notifications Demo[414:66091] [CDVTimer][intentandnavigationfilter] 8.823991ms</p>
  
  <p>2018-11-08 17:50:54.708 Push Notifications Demo[414:66091] [CDVTimer][gesturehandler] 0.429988ms</p>
  
  <p>2018-11-08 17:50:54.708 Push Notifications Demo[414:66091] Starting Firebase plugin</p>
  
  <p>2018-11-08 17:50:54.709 Push Notifications Demo[414:66091] [CDVTimer][firebaseplugin] 0.813961ms</p>
  
  <p>2018-11-08 17:50:54.709 Push Notifications Demo[414:66091] [CDVTimer][TotalPluginStartup] 13.291001ms</p>
  
  <p>2018-11-08 17:50:54.739 Push Notifications Demo[414:66091] GoogleService-Info.plist found, setup: [FIRApp configureWithOptions]</p>
  
  <p>2018-11-08 17:50:54.802 Push Notifications Demo[414:66091] [Crashlytics] Version 3.10.7 (130)</p>
  
  <p>Nov  8 17:50:55  Push Notifications Demo[414] : 5.7.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50101000 started</p>
  
  <p>Nov  8 17:50:55  Push Notifications Demo[414] : 5.7.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:</p>
  
  <p><a href="https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging" rel="nofollow noreferrer">https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging</a></p>
  
  <p>to ensure proper integration.</p>
  
  <p>Nov  8 17:50:55  Push Notifications Demo[414] : 5.7.0 - [Firebase/Messaging][I-FCM002023] The object  does not respond to -messaging:didReceiveRegistrationToken:. Please implement -messaging:didReceiveRegistrationToken: to be provided with an FCM token.</p>
  
  <p>Nov  8 17:50:55  Push Notifications Demo[414] : 5.7.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled</p>
  
  <p>2018-11-08 17:50:56.008 Push Notifications Demo[414:66091] Resetting plugins due to page load.</p>
  
  <p>2018-11-08 17:50:56.165 Push Notifications Demo[414:66091] Connected to FCM.</p>
  
  <p>2018-11-08 17:50:56.169 Push Notifications Demo[414:66091] InstanceID token: e2Ds2K2cQbI:APA91bE…MqU</p>
  
  <p>2018-11-08 17:50:56.358 Push Notifications Demo[414:66091] Finished load of: file:///var/containers/Bundle/Application/39065AA6-1AEA-4EF5-A4D9-009185D6BE6D/Push%20Notifications%20Demo.app/www/index.html</p>
  
  <p>2018-11-08 17:50:56.373 Push Notifications Demo[414:66153] [Fabric] failed to download settings Error Domain=FABNetworkError Code=-5 "(null)" UserInfo={type=2, request_id=7f2cefa10b4df773f0466752024ec30a, content_type=application/json; charset=utf-8, status_code=403}</p>
  
  <p>2018-11-08 17:50:56.537 Push Notifications Demo[414:66091] Received Event: deviceready</p>
  
  <hr>
  
  <p>The app is running on the connected iPhone (<em>iOS version 9.3.5</em>) and is displaying the demo Cordova app's “Device Ready” splash screen.</p>
  
  <p>Now I should be able to send a Push Notification to the iPhone running the Cordova app? To do this I go to the Firebase Console and send a Cloud Message (I am using an APNs Auth Key), I send it specifying the Instance token (shown in the previous Console output) in the “Test on device” option, and I get the following output in the Xcode console:</p>
  
  <hr>
  
  <pre><code>2018-11-08 18:03:31.091 Push Notifications Demo[414:66091] {
      "collapse_key" = "com.XXX.pushnotificationsdemo";
      from = 293106682585;
      notification =     {
          body = "Test notification to iOS device";
          e = 1;
      };
      tap = 0;
  }
  </code></pre>
  
  <hr>
  
  <p>Great! The device received the notification. BUT I get no notification pop-up on the device itself.</p>
  
  <p>NOTE: the app has not asked permission to use Push Notifications (I did get this request when I was test using the “fcm” plugin)</p>
  
  <p>OK, so this could be because the App is in the foreground? So I push the Home button on the iPhone to put it into the background and I get this in the Xcode console:</p>
  
  <hr>
  
  <p>2018-11-08 18:07:05.856 Push Notifications Demo[414:66091] Disconnected from FCM</p>
  
  <hr>
  
  <p>Not so great, the device has now disconnected from FCM!</p>
  
  <p>I bring the app back into the foreground and voila! The console now reports:</p>
  
  <hr>
  
  <p>2018-11-08 18:08:26.581 Push Notifications Demo[414:66091] Connected to FCM.</p>
  
  <p>2018-11-08 18:08:26.586 Push Notifications Demo[414:66091] InstanceID token: e2Ds2K2cQbI:APA91bE…MqU</p>
  
  <hr>
  
  <p>So things are not going very well! It appears my Cordova app is not using APN to push notifications to the Device but is instead using Firebase directly (assumption: Firebase cannot process when the App is in the background and APN can, therefore, APN is not being used)</p>
  
  <p>This is my second day on trying to get APN working through the cordova-plugin-firebase (I’ve also tried the “fcm” plugin and this came up blank as well), needless to say the Cordova Android version worked out of the box.</p>
  
  <p>Anybody any thoughts on what I am doing wrong?</p>
  
  <hr>
  
  <p>Instructions I have used to set-up Firebase for use with iOS:</p>
  
  <p><a href="https://medium.com/@felipepucinelli/how-to-add-push-notifications-in-your-cordova-application-using-firebase-69fac067e821" rel="nofollow noreferrer">https://medium.com/@felipepucinelli/how-to-add-push-notifications-in-your-cordova-application-using-firebase-69fac067e821</a></p>