-
Notifications
You must be signed in to change notification settings - Fork 993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heads up notification not working in foreground #365
Comments
It is working in foreground but it doesn't make a sound. The message is received, like you would click on it, receiving it in background. In your code, onNotification, you can display the message in a modal for example. FYI |
I am getting notification on Android but on iOS the onNotification method is not firing at all. I am running iOS 10.3, in console, I see messages that everything is initialized and token is registered but when a send a notification via the firebase console, I receive it on Android but not on iOS. The plugin version i am running is 2.1.2 (latest one) Please assist |
Did you set up your ios certificates in firebase? |
@CowboyCode I'm using your fork and all works for me on iOS excepting when sending data notifications, the xcode log shows:
There's an open PR on this issue but it unfortunately conflicts with your modifications I was just wondering if you somehow got this working for you.. thank you (and for spending time trying to assist others on this repo) |
I will test it on Monday morning and let you know |
@CowboyCode Thank you |
@1N50MN14 It works for me, see my Xcode log below.
I receive the messages as below
Then I pop the message up using
After that I redirect to a notification page which shows all received notifications, I save those in sqlite. Without the implemented code, you would not know that you got a message, there is noise when the app is in foreground. |
@blumanski Thank you for the feedback; this works for you because you're sending it as notification message and not as a data message, the above works for me as well. I'm sending a data message in accordance to the FCM data message specs (https://firebase.google.com/docs/cloud-messaging/concept-options) whereby you don't specify the |
@1N50MN14 lol, I have to many github accounts... Ah, ok, I just add my data to the notification, FCM does not display the data, just the header and body when the app is in the background. The data has still to be done in the code. Can't you send it as notification and send the data with it? I add heaps of data to it |
@blumanski :) Yes I can send a notification with data in it but then it would be displayed to the user by the OS whereas the intention of sending a data message is to let the app deal with the processing / handling of the data. In my case, I'm using push messages to notify users with things such as "someone liked your post" and data messages to instruct the app to perform certain tasks that do not involve user interaction. To test this, remove the |
I will check that out |
@1N50MN14 |
Yes this is it! Thank you for looking into it despite not needing it yourself, very much appreciated @blumanski |
@1N50MN14 Haven't done a pull request yet |
Oh bummer, will test it right away one sec |
@CowboyCode Yup, same error: hmmmm this is strange.. did you download the release from https://firebase.google.com/docs/cpp/setup? |
Na, the ios version, 4.1.0. The error must come from the plugin code, I am not a object-c developer :-) |
@blumanski ahh bummer.. neither am I, this language is just too weird.. ;) |
@1N50MN14 it looks like everything is in the code, I guess it would take somebody 5 minutes to add this :-) It would take me probably 10 hours lol, if it even would work :-) |
@1N50MN14 Cheers |
Thank you @CowboyCode! |
True, the commit must have failed, I will recommit it tomorrow |
@CowboyCode That would be great thank you! |
Hi guys. I have forked ostownsville's repo as well just like @CowboyCode. I found a bug completely unrelated to this issue to do with copy google-services.json. BUT the reason why I am commenting is because if @CowboyCode is going to put that commit up...
...will you merge with ostownsville? |
@chrisjpalmer I have already added this pull request, regarding the copy google-services.json to the repo. And #364 (untested) You can double check it at the moment under I will do some testing tomorrow, and then I will merge it into ostownsville and create probably a pull request here. Cheers |
@CowboyCode Just tested it, unfortunately the same error message still appears :(
|
@CowboyCode Great, thanks for the clarification! Also thank you for contributing to this plugin. We seriously need it! I can see that you have merged #370 into ostownsville/cordova-plugin-fcm. I actually cloned ostownsville and found a small problem with the way google-services.json is copied. It was only a one liner. I could have it wrong but, the .json started copying properly for me after making the change. NOW... BACK TO THE ORIGINAL THREAD |
@1N50MN14 @chrisjpalmer All is up to date but the error for data messages is still there. I create a new issue for that. Cheers |
Hi there. Very sorry. Our latest P.R. has broken the plugin I am guessing.
Please revert to a pervious commit by using:
cordova plugin add `https://github.com/ostownsville/cordova-plugin-fcm.git#COMMIT_HASH <https://github.com/ostownsville/cordova-plugin-fcm.git#COMMIT_HASH>` where commit hash is the commit you would like to use of our plugin.
If using Ionic, prefix with ‘ionic’.
Chris
… On 3 Oct 2017, at 9:38 am, Ayman Mackouly ***@***.***> wrote:
@chrisjpalmer <https://github.com/chrisjpalmer> I think it would be a good idea imho to have a choice on when to initialize firebase, one can choose either on startup or wherever it makes sense.. in my case this has been problematic because the popup is blocking and it appears exactly where I don't want any blocking alerts ;) I'm also a bit concerned Apple may take notice on alerts showing up first thing..
The immediate concern now though is push notifications not showing up on iOS.. it's been stopping me the last few days from pushing the app to the app store :(
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#365 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AcaUO2Ht6Qi2QQ9LnjQg37r49jCZDVsJks5soWXxgaJpZM4Ouhg->.
|
@chrisjpalmer Thank you I'll try to revert 521e288 One question, the plugin's js automatically invokes https://github.com/ostownsville/cordova-plugin-fcm/blob/master/src/ios/FCMPlugin.m#L26 va https://github.com/ostownsville/cordova-plugin-fcm/blob/master/www/FCMPlugin.js#L40 - i wrapped that inside an |
Hi there. Revert to a8e14ad. I don't think the ready method is linked to anything in code. It probably needs to be removed. If you check out https://github.com/ostownsville/cordova-plugin-fcm/blob/master/src/ios/AppDelegate%2BFCMPlugin.m you'll see that the initialisation routine |
(thank you) right so I see a void method |
Yes so checkout this forum post on the Objective-C load method. https://stackoverflow.com/questions/13326435/nsobject-load-and-initialize-what-do-they-do load() is called by the runtime. load() performs method swizzling which allows us to hook into the app-delegate's applicationDidFinishLaunching method. Then we can init firebase. |
Great, so from the code base point of view what could stop us from having custom initialization? of what I see this is the recommended approach for plugins https://cordova.apache.org/docs/en/latest/guide/platforms/ios/plugin.html |
Hi there. So I have tested the plugin this morning on iOS 10.3.3. Notifications Not Working
I should stress that in between tests I...
Conclusion: Notifications appear to be working (at least from my perspective). Custom Initialisation Hope this helps Chris |
@chrisjpalmer I finally figured out the issue! It was a bug in iOS 11!!! Upgraded to 11.1 and push notifications started to arrive, damn it Apple!!! Thank you so much for the help!! Going to look into the init thing now |
@1N50MN14 Have you got 11.1 or 11.0.1 in my device i have 11.0.2 but this plugin not working |
@raghuyt hmm I just upgraded to 11.0.2, no incoming notifications anymore... On 11.0.1 I was receiving notifications, but when the app was closed / in background mode, notification data was not being forwarded to the app.. Only @chrisjpalmer or @CowboyCode can rescue us on this one |
I work at the moment on ios adk upgrade 4.3.0. may that will help. |
@CowboyCode Happy to help with testing if you wish |
@1N50MN14, in regards to
Do you mean that your app was not being "woken up" using the silent background notification feature which apple advertise in their documentation? This is meant to be so your application can do a little processing before you open it, making it more performant. If you are referring to this, and you are not talking about notification banners (the iOS notification center)... then I have had no success with this either. I don't think it works with APNS anymore. However our plugin does receive the background notification on boot as referenced in Point 2.1 in our PR (at least on iOS 10.3.3). Now, it occurred to me the other day that this may be due to the following entitlement not being ticked in XCode, I am actually willing to test this to see if we made this mistake: Kind Regards |
@chrisjpalmer Yeah I was referring to the notification banner, i.e. the notification showing up on the os notification screen.. the "boot" issue I worked around it by sending the same notification twice, both as normal notification as well as data notification and let the app handle it. When it comes to the notification banner, I couldn't find a workaround either, basically users tap the notification, app opens up, they don't see it in the app so they don't know where to go to open the post (my notifications are like "christ published a new post", goes into an app page which lists the notifications). Everything else worked just fine until 11.0.2 PS: In addition to the Remote notification entitlement I also have "Background fetch" checked, is this needed for our plugin? |
@1N50MN14 thank you now its working in all IOS versions ,till now IOS version 11.0.2 its working all devices |
@1N50MN14 That would be great :-) |
@CowboyCode On it, I'll test it in a bit (about couple of hours) and report back |
@CowboyCode Ok I can confirm not only that it's working now but also tapping on the notification banner relays the data to the app as well, two problems solved at once!! woohoo!!!! 👍 |
Great, I do the pull request now :-) |
@CowboyCode The only thing which is still problematic is notifications not arriving the app when in background mode; but at least notifications are arriving and users are being altered, now I'm thinking to solve this by saving outgoing notifications in the database and load them from there when the app resumes.. a bit of a hassle but at least it's a solution, I'm just happy this plugin works :) |
Hev everyone nice work. @1N50MN14 I know this might not be much help... But we found that even though background notifications don't work, if your notification was a silent notification (ie. nothing in the |
I have just tested the background notifications on ios 11.0.3, that was working fine. In my test, I was sending notifications to the devices using the token, not subscribed channels. |
I'm experiencing exactly the same case as @chrisjpalmer my initial workaround was whenever I send a loud notification I send it as data message as well, the problem is that in my specific case I'm using AWS SNS to handle notification sends out, and for topics SNS (unlike with direct SNS endpoints) it expects the message payload to be a regular push notification otherwise it'll throw an error. That leaves me with two options, either drop topics and send messages one by one, or persist the notifications; database writes versus reads, reads are lighter, writes allow to persist both require some coding, opting for writes at least if a user installs the app on a different device I will be able to recover previous notifications and show them in the notification section of the app.. But yeah, you're right about silent data notifications; I'm just "unlucky" with my use case.. // @CowboyCode |
@1N50MN14 @CowboyCode I am having issue when app is in foreground on Android device. Heads up notification doesn't work.
|
I am experiencing the same issue as @savanr. I'm only recieving notifications on android when it is in either the background or killed. When the app is in the foreground I recieve no notifications at all.... Does anyone know why push notifications isn't working when the app is in the foreground? |
Hi guys. I am working on a fork of this project with Cowboy code located here: Give this a try. If you have any issues, post it on our repository. |
Apparently recieving push notifications in the foreground is not possible through firebase cloud messaging. What is possible though is sending data messages together with your notifications and handling the data inside your app to show some sort of modal when a notification is recieved in the foreground. I'm currently working on a cordova plugin to play the native push notification sound when it is recieved in the foreground. This way I can recreate the experience of getting a push notification from within my app through data messages send with the notification. Sorry I didn't figure this out sooner.... |
@Simbaclaws : is this the case for both Android and ios? I had the same issue for Android, but don't have ios implementation yet. |
@ourarash I haven't tested it on iOS yet, but will soon in the future. I do think this is the same though. I've read about it somewhere and can confirm this is the case for android. I'll let you know if this is the case for iOS aswell but I'm pretty certain it's how it is intended to work. |
Hi all, I can confirm it's both the case in iOS and Android: foreground notification you need to handle the "data" part to issue any type of result as no notification is sent. I think this is by design in FCM. |
Heads up notification is not working, even setting the priority as "High" and checked the file MyFirebaseMessagingService.java.
The sendNotification method is commented in onMessageReceived method.
The text was updated successfully, but these errors were encountered: