0
votes

I'm trying to get the push notifications working. Starting with the client app I added the FCM plugin to the ionic project, imported in app.module.ts and listed it in providers.

Then in app.component.ts

import { FCM } from '@ionic-native/fcm';
constructor(..., public fcm: FCM) {

platform.ready().then(() => {
  ...
  this.fcm.getToken().then(token=>{
    console.log(token);
  });
  this.fcm.onNotification().subscribe(data => {
    if(data.wasTapped){
      console.log("Received in background");
    } else {
      console.log("Received in foreground");
    };
  });
  this.fcm.onTokenRefresh().subscribe(token => {
    //backend.registerToken(token);
    console.log('token changed ', token);
  });
  this.fcm.subscribeToTopic('general');
});
}

And I wanted to test how does it work from the FCM website. It works when I send it directly to device through its token. It works also when I send it to devices subsribing the topic 'general'. But it doesn't work when I send it just to the users of the app even though it shows me that there are 2 users right now. example here

Then I also added the FCM server key to Azure Notification Hub and wanted to send a test message from Azure portal, but it wasn't delivered.

If I don't subscribe to any topic in the app.component.ts it also doesn't receive any notification designated to all users of the app.

1
Any luck with this? We are also trying to make FCM work for our ionic app using azure notification hub.Ajinkya
@Ajinkya, You could use the Ionic 3 sample in the Azure Notification Hubs Samples -github.com/Azure/azure-notificationhubs-samples/tree/master/… that John highlighted on your thread -stackoverflow.com/questions/56294163/…AjayKumar-MSFT

1 Answers

0
votes

Apologies for the delayed response here. Just following-up on this from Ajinka's response above. @Szymon, You have stated in your original post "But it doesn't work when I send it just to the users of the app even though it shows me that there are 2 users right now", since it does not work directly with FCM, so typically it’s not going to work with Azure Notification Hubs since Azure Notification Hubs is just sending it through FCM. So, you must identify and isolate the issue with FCM fist.