Open laychar opened 6 years ago
Similar issue here.
I get messages only in foreground and not in background. I've tried adding the instruction window.FirebasePlugin.grantPermission()
but with that I can't receive also the foreground.
The capabilities enabled are push notification and remote notifications in background mode.
I think my situation is worse than yours. My app can't even get push notification from server. And server-side only show following error log. {"multicast_id":7865216371953735195,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} {"multicast_id":5925458101353466197,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]} But after I call the function window.FirebasePlugin.unregister() and getToken() again, my app can get push notification only on foreground. Long ago my app's push system works well but suddenly It can't work.. I don't know why this problem occurs.
@chin8 @laychar are you including a click_action in the notification you are sending? There was an issue I encountered that iOS would not deliver messages in the background if you included a click_action in the notification.
Can you post your notification JSON blob that you are sending from the server?
@briantq what is the click action? And can you advise me? My app can not get notification even on foreground mode.
I'm not sure if it can help up but I've found the solution for me.
Reading the log of the XCode console I found this message
Error while reading embedded mobileprovision Error Domain=NSCocoaErrorDomain Code=260 "The file “embedded.mobileprovision” couldn’t be opened because there is no such file.
The solution I tried is this
In particular the problem was the file copy-www-build-step.js in the folder platform/ios/cordova/lib has the following lines
// Code signing files must be removed or else there are
// resource signing errors.
shell.rm('-rf', dstWwwDir);
shell.rm('-rf', path.join(dstDir, '_CodeSignature'));
shell.rm('-rf', path.join(dstDir, 'PkgInfo'));
shell.rm('-rf', path.join(dstDir, 'embedded.mobileprovision'));
I commented the last one so the result is
// Code signing files must be removed or else there are
// resource signing errors.
shell.rm('-rf', dstWwwDir);
shell.rm('-rf', path.join(dstDir, '_CodeSignature'));
shell.rm('-rf', path.join(dstDir, 'PkgInfo'));
//shell.rm('-rf', path.join(dstDir, 'embedded.mobileprovision'));
Now it works in my case
@chin8 I didn't follow your instruction because I did not have that error log. But thanks to your link, I solved my problem. First) I changed build system by doing following steps. XCODE file > Project Settings > (use Legacy Build system instead of New Build system.) (By doing this you may get notification even in foreground. To fix this problem you should follow next step) Second) follow the #835
After that you can get notification on background mode. Thanks.
Describe the bug A clear and concise description of what the bug is. I got the following two error. {"multicast_id":7865216371953735195,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} {"multicast_id":5925458101353466197,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}
And following is my code.
var changetoken= function(){ alert('chtk'); window.FirebasePlugin.getToken(function(token) { alert('0'); var token=token||'n';
if(token.length<10){ chtk(); return;
}
alert('1'); var data={};
data.tk = token; window.localStorage['tk']=token; data._id = window.localStorage['_id']; data.id=window.localStorage['id']; data.name=window.localStorage['name']; alert('2'); $.ajax({ type:'POST', data: JSON.stringify(data), contentType: 'application/json',
url:url+'/stk', success:function(output){ if(output.status==100){ alert('success'+token); }else if(output.status==500){ alert('token update failed1'); }else{ alert('token update failed1');
}
}
}); }, function(error) { console.error(error); });
}
my app call that function whenever users turn on the app. It works well in android. But It dose not work well in IOS. Only at the first time my app is turned on, that function is called well. After that my app often(NOT ALWAYS) get error when my app call that function. Although my app called that function successfully I only get following error. {"multicast_id":7865216371953735195,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} {"multicast_id":5925458101353466197,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}
+)When I call the function "window.FirebasePlugin.unregister(changetoken);" My app' push system sometime(NOT ALWAYS) works well. And get push message only on foreground! My app is very changeable.... I need your help. thank you.
Plugin Version Run
cordova plugin list
to find out what version of cordova-plugin-firebase you are running with 2.0.5 Desktop (please complete the following information):Smartphone (please complete the following information):