Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

IOS cloud notification on click not triggering addOnMessageReceivedCallback #304

Closed
suralal opened this issue Mar 3, 2017 · 4 comments
Closed
Milestone

Comments

@suralal
Copy link

suralal commented Mar 3, 2017

Hi,

i am using firebase cloud messaging in my nativescript app for both ios and android.The plugin is working fine in android with addOnMessageReceived is getting invoked on click of notification,but in ios when the notification button is clicked firebase.addOnMessageReceivedCallback() is not getting invoked. the app gets opened in home page.Is there any addtional steps which we have to carry out for ios

@EddyVerbruggen
Copy link
Owner

Shouldn't be, perhaps you can share your project with me so I can take a look? Btw, are you using Angular?

@suralal
Copy link
Author

suralal commented Mar 3, 2017

No i am using nativescript core.Attaching the file

var frameModule = require("ui/frame");
var topmost = frameModule.topmost();
var application = require("application");
var cache = require( "nativescript-localstorage" );
var firebase = require("nativescript-plugin-firebase");
var topmost = frameModule.topmost();
var globalUrl = cache.getItem("url");
var loginStatus = cache.getItem("loginStatus");
var signUp = cache.getItem("signUp");

application.cssFile = "./app.css";
var imageItem = require('./views/report/image-item');
var http = require("http");
var LoadingIndicator = require("nativescript-loading-indicator").LoadingIndicator;

firebase.addOnMessageReceivedCallback(
function(message) {
loader.show();
if(message._id == undefined || message._id == null){
if(globalUrl != null || globalUrl != undefined ){
if(loginStatus != null){
loader.hide();
var topmost = frameModule.topmost();
var navigationOptions={
moduleName:'views/home/main-page'
}
frameModule.topmost().navigate(navigationOptions);
}
else{
loader.hide();
var topmost = frameModule.topmost();
var navigationOptions={
moduleName:'views/login/login'
}
frameModule.topmost().navigate(navigationOptions);
}
}
else{
loader.hide();
var topmost = frameModule.topmost();
var navigationOptions = {
moduleName:'views/signup/signup'
}

			frameModule.topmost().navigate(navigationOptions);
		}
	}
	else{
		var data = cache.getItem("report");		
		var tempUrl= global.url+"/api/showReport/?studentId="+message._id
		var dataList = JSON.parse(data)
		http.request({
			url: tempUrl,
			method: "GET",
			headers:{ "x-auth-token":global.authToken,"x-user-id":global.userKey }
		})
		.then(function (response,error) {
			if(response.statusCode == 200){
				var dailyReport = response.content.toJSON().message
				var imageUrl = dailyReport.data.profileImageUrl
		       	var count = 1
	    		var obj = {}
				var data = new imageItem.ImageItem(imageUrl); 
				dailyReport.data.profileImageUrl  = data
				// dataList = []
				if(dataList != null){
					if(dataList.length  >= 5){
						dataList.shift();
						var stringifyArr = JSON.stringify(dataList)
						cache.setItem("report",stringifyArr);
						cache.setItem("reportType","gcm");
						cache.setItem("reportId",message._id);
						loader.hide(); 
						var navigationOptions={
						moduleName:'./views/report/dailyReport',
						context:{
							todaysReport: message._id,
							reportType : "gcm"
								}
						} 
						frameModule.topmost().navigate(navigationOptions);
					}
					else{
						dataList.push(dailyReport)
						var stringifyArr = JSON.stringify(dataList)
						cache.setItem("report",stringifyArr);
						cache.setItem("reportType","gcm");
						cache.setItem("reportId",message._id);
						loader.hide(); 
						var navigationOptions={
							moduleName:'./views/report/dailyReport',
							context:{
								todaysReport: message._id,
								reportType : "gcm"
									}
						}
						frameModule.topmost().navigate(navigationOptions);
					}
				}
				else{	
						dataList = []
						dataList.push(dailyReport)
						var stringifyArr = JSON.stringify(dataList)
						cache.setItem("report",stringifyArr);
						cache.setItem("reportType","gcm");
						cache.setItem("reportId",message._id);
						loader.hide(); 
						var navigationOptions={
						moduleName:'./views/report/dailyReport',
						context:{
							todaysReport: message._id,
							reportType : "gcm"
								}
						}
						frameModule.topmost().navigate(navigationOptions);
				}
			}
		},
		function (e) {
			loader.hide(); 
			dialogsModule.alert({
			message: "Daily Report for the current day has not been generated",
			okButtonText: "OK"
			});
		});	
}

});

@EddyVerbruggen
Copy link
Owner

I'm sorry but that doesn't deploy to my phone. Can you share something I can reproduce the error with?

@EddyVerbruggen
Copy link
Owner

If this was an issue with the plugin, then it's fixed in 3.11.0

EddyVerbruggen pushed a commit that referenced this issue Mar 22, 2017
EddyVerbruggen added a commit that referenced this issue Apr 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants