-
Notifications
You must be signed in to change notification settings - Fork 34
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
added a little support for Android Oreo #102
Conversation
I believe that each notification channel can only have one configuration for sound + importance so that if your push has a custom sound it will not use that -- it will only play the sound used for the first push sent on that channel. In your changes, you are not setting the sound for the channel, so I'm guessing it plays the default sound. Did you see that behavior in your tests? |
@emilyfeder i did not try, this is a very little support just for having notifications shown on Oreo (see #97 ) and i have not considered custom sound at all. At the moment this PR add support just for one channel: you can only specify its name via tiapp.xml It would be nice to completely support Oreo, with multiple channel handling and so on :) |
Does this solution actually work when targeting API 26 and running on an Android 8 device? The channel implementation here seems fine but the BroadcastReceiver is still using "startWakefulService" which is no longer supported when you target 26 due to the new background restrictions. So in theory the service would never be started. |
@SeanMaraj Doesn't look like the notifications are received if the service is not actually running :/ Did you have any luck finding a solution? |
@miniman42 I'm currently migrating to Firebase using this module: https://github.com/hansemannn/titanium-firebase-cloud-messaging Alternatively, if you want to use continue to use this Goosh module, you'll have to compile it yourself and be sure to use "startForegroundService" instead of "startWakefulService". I did that and the service started fine. Unfortunately, I was having some trouble getting the actual notification to display properly. So that's when I decided to use the new Firebase module from Hans. It's more work to set up but Firebase seems pretty worth it. |
@SeanMaraj Thanks for the info - I'm on a similar mission to upgrade to FCM and API level 26, we've already a fairly heavily customised version of ti.goosh :) |
@slash-84 So Hans' module by default doesn't really let you show a notification when the app is closed (unless i'm missing something). But I'm literally working on that feature right now for my app. You just have to build and show your notification in the "onMessageReceived" function in TiFirebaseMessagingService.java. No extra service is required from what I can tell. |
Ahh yes, just took a peek at the doc's there https://developers.google.com/cloud-messaging/android/android-migrate-fcm - I'll have a go at updating my goosh to use FCM directly, looks pretty trivial #famouslastwords |
I ended up using the module you mentioned: https://github.com/hansemannn/titanium-firebase-cloud-messaging in my app. |
@emilyfeder did you have to do anything special with titanium-firebase-cloud-messaging to get notifications to work from the background? No matter what I do, I can't get the data to show up in Ti.App.Android.launchIntent getExtra methods. It seems to just not have access to the data that was in the payload of the notif. I also tried Ti.Android.currentActivity but the data wasn't there either. Any help is appreciated, I'm hoping to learn how you got it going. |
Yes, you need to do something a little different when sending the message.
You need to set both a notification and data payload in the message to have
the extra in the launch intent. Take a look at this issue thread in the
titanium-firebase-cloud-messaging repo for details:
hansemannn/titanium-firebase-cloud-messaging#13 (comment)
…On Thu, Aug 30, 2018 at 2:36 AM David Fox ***@***.***> wrote:
@emilyfeder <https://github.com/emilyfeder> did you have to do anything
special with titanium-firebase-cloud-messaging to get notifications to work
from the background? No matter what I do, I can't get the data to show up
in Ti.App.Android.launchIntent getExtra methods. It seems to just not have
access to the data that was in the payload of the notif. I also tried
Ti.Android.currentActivity but the data wasn't there either. Any help is
appreciated, I'm hoping to learn how you got it going.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#102 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZk_or4oHofCsnBB2DQ8ZCFZWbKQY2dks5uV5XsgaJpZM4SXJpB>
.
|
@emilyfeder thanks for the info. That's what I was trying, but it doesn't seem to work. I confirmed the data was coming through because the notification and data are successfully received if the app is in the foreground. But once in the background, the notification is received but when you navigate to the app via the notif, the data isn't showing up anywhere. It's definitely a notif + data, and works in the foreground, so not sure if I'm doing something wrong or this some kind of issue. But the data doesn't seem to be present on any of the activity/intents. |
Are you using the firebase console to send test messages so that you can eliminate any issues you may have in your push server? They have 'advanced' message options where you can set the data payload. |
@emilyfeder thank you. I will try sending from the console. Two more questions if you don't mind - where in your app are you calling Ti.App.Android.launchIntent.getStringExtra? (I've tried numerous places, but no luck. ex. the initial window open even handler, before initial window open, etc.) I'm wondering if I'm calling it too late in the lifecycle or maybe just the wrong place, to have it not be there at the point I'm looking for it. Also, what version of the Titanium SDK are you using? I tried with various 7.x builds but no luck. |
In the classic Titanium app I am getting data from intent in app.js I think for alloy app you will get it in index.js
I think your problem is related to payload. Don't forget to make necessary changes on server side. There are two section in notification payload.
Please check server code given by Hans on
|
@RavindraChherke thanks for all of the info. I am using a classic app so I have my code in app.js. I tried that code, but unfortunately, no luck. I can see the data is coming through properly, because it works if the app is in the foreground when the notif is received (didReceiveMessage) I'm able to see the passed along data. But unfortunately, when the app is backgrounded, no matter what I've tried I can't seem to get it to find any data on the intent. |
We're merging this solution for now, as a starting point. We need to address the biggest problems first, and then implement a more comprehensive solution. |
No description provided.