I have been using ionic and FCM (Firebase Cloud Messaging) for notification.
I get the notification on my app and now I have 2 issues. First, if its a normal notification like not with advanced options in Firebase Console > Notification, then it doesn't play any sound, but when it's data Notification, then it does play a sound. Second, I want to open a particular page of my app on notification click.
So how do I do that?
Note: I am using ionic not an ionic2.
First issue: We have sound in both situations. Have you tried to send an empty data object?
Second issue: Just assuming you use the Cordova FCM plugin. Otherwise install it with
cordova plugin add cordova-plugin-fcm --save
Use the data with an ID to the right datapage and then do something like:
angular.module('app', ['ionic']) .run(function ($ionicPlatform) { $ionicPlatform.ready(function() { if(window.cordova) { FCMPlugin.onNotification( function(data){ if(data.wasTapped){ //Notification was received on device tray and tapped by the user. $state.go('yourpage', {id:data.pageId}); console.log('onNotification tapped true'); } else { //Notification was received in foreground. User needs to be notified. console.log('onNotification tapped false'); } }, function(msg){ console.log('onNotification callback successfully registered: ' + msg); }, function(err){ console.log('Error registering onNotification callback: ' + err); } ); } }); });