Push notification with Firebase on iOS

Hi, i’m testing push notification and in Android it’s working, But iOS is not receiving notification. I implemented the example of the Fuse documentation in link FuseJS/Push Module (JS).

I’ve set up the following scenario:

1º - Backend server in node.js
var fetch = require('node-fetch');

var API_ACCESS_KEY = 'AIzaSyD2nLYa2M.........U6EeIuecpU';
var DEVICE_ID1 = "APA91bHPRRcMA4e_rl-.........WYhFYdwci"; //Android
var DEVICE_ID2 = "7568137cccabf20502ff2.........c8b4c7b285"; //iOS

var msg = {
  method: 'POST',
  headers: {
    'Authorization': 'key=' + API_ACCESS_KEY,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    registration_ids: [ DEVICE_ID1,  DEVICE_ID2],
    data: {
      notification: {
        alert: {
          title: 'Well would ya look at that!',
          body: 'Hello from some other app'
        }
      },
      payload: JSON.stringify({key1: 'value1', key2: 'value2'})
    }
  })
};

fetch('https://fcm.googleapis.com/fcm/send', msg).then(function(response) {
  console.log(response);
}, function(error) {
  console.error(error);
});
2º - Fuse app

In the unoproj I added “Fuse.PushNotifications” in Packages and

"Android": {
  "Package": "com.apps.pushmonteiro",
  "GooglePlay": {
      "SenderID": "7010.....0844"
  }
},
"iOS": {
  "BundleIdentifier": "com.apps.pushmonteiro",
  "DevelopmentTeam": "5MW....4JY"
}

In the MainView.ux

<App>
  <iOS.StatusBarConfig Style="Dark"/>
  <Android.StatusBarConfig Color="#c2cac4"/>

  <ClientPanel>
    <ScrollView>
      <StackPanel ItemSpacing="8">
        <Each Items="{list}">
          <Text Value="{}" TextWrapping="Wrap"/>
        </Each>
      </StackPanel>
    </ScrollView>

    <JavaScript>
      var Observable = require('FuseJS/Observable');
      var list = Observable();
      var push = require("FuseJS/Push");

      push.on("registrationSucceeded", function(regID){
        list.add("Reg Succeeded: " + regID);
      });

      push.on("error", function(reason) {
        list.add("Reg Failed: " + reason);
      });

      push.on("receivedMessage", function(payload) {
        list.add("Recieved Push Notification: " + payload);
      });
      
      module.exports = {
        list:list
      }
    </JavaScript>
  </ClientPanel>
</App>

In the registrationSucceeded function you are able to register for both platforms. While running the service node.js is receiving notification on Android, but is not receiving on iOS.

Permissions are enabled, connection with wi-fi is good. When sending a notification through the Firebase Console for iOS also is not working.

Version
Operational system: macOS Sierra version 10.12.5
Fuse version 0.37.0 (build 12978)
Copyright (C) 2017 Fusetools

Another detail, when generating the app, need to open the project in Xcode and mark the configuration to allow “Push Notifications”, otherwise it is not registering. I wish I did not control it manually. If possible, please make it work.

Thanks in advance.

Hi Lucas,

there is a bit of a difference in the Google Firebase and Apple APN support. Please take a look at this repository which tells the whole story about limitations and how you can overcome them currently.

Is it not possible to use the Fuse library to make the push work on both platforms?

I’m also looking for a simple solution to push on both platforms…

Push notifications are likely never going to be simple on either of the platforms, but there’s this repo that shows how you can use Fuse.APNS for iOS & Fuse.Firebase.Notifications together in the same project.

The onRegistrationSucceeded and onReceivedMessage events are pretty much clear and works on both platforms. Also, sending push notification works in Android with firebase (I’m using this api https://fcm.googleapis.com/fcm/send).

What about sending push notification with Fuse.APNS ? Is there some example of code for sending push notification in iOS and is it possible to send push notification with Fuse.APNS in iOS via javascript ?

@Zoran: the link shared in the post right above yours includes all the information you need to get push notifications working on both Android and iOS.

The link has information for registration and recieveing a push notification, but not for sending a push notification. But I found this https://github.com/node-apn/node-apn It is a nodejs module for sending push notifications in iOS devices. Is it possible to import this and use in my fusetools project (especcialy in my .unoproj file) and how ?

Oh. I don’t know about that node package, but perhaps this section in docs helps?

Normally, you send push notifications from a backend, so there’s little use (aside from just testing) to have the capability to send push notifications from an app.