Comments (7)
Thanks for reporting this.
I don't know why it's -1000 at the beginning, but you're right according to the android doc. Will have a check.
from com.unity.mobile.notifications.
Thanks! So it's a different story on device below Android 8, as there is no notification channel support.
from com.unity.mobile.notifications.
I looked into this issue today, would like to share what I found.
-
Android document said VISIBILITY_PUBLIC is 1, https://developer.android.com/reference/android/app/Notification#VISIBILITY_PUBLIC. But I found if you set a channel to
Show all notifications ...
inSystem Settings
,NotificationChannel.getLockscreenVisibility()
will return -1000. Also if you don't set the LockScreenVisiblity when creating the notification channel, it will be -1000 by default. -
NotificationChannel.setLockscreenVisibility() won't work from code anyway. check the comment here by searching
Only modifiable by the system and notification ranker.
. This means the value can only be changed fromSystem settings
or byAndroid Notification Ranking Service
. I did a quick experiment by doing below
protected void createNotificationChannel(NotificationManager notificationManager)
{
NotificationChannel channel = new NotificationChannel(k_ChannelId, "Test Default", NotificationManager.IMPORTANCE_DEFAULT);
Log.w("Create Channel", String.format("Default lockscreen: %d", channel.getLockscreenVisibility()));
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
Log.w("Create Channel", String.format("Set lockscreen %d", channel.getLockscreenVisibility()));
notificationManager.createNotificationChannel(channel);
}
protected void printNotificationChannel(NotificationManager notificationManager)
{
NotificationChannel channel = notificationManager.getNotificationChannel(k_ChannelId);
Log.w("Print Channel", String.format("Get lockscreen %d", channel.getLockscreenVisibility()));
}
I got the below results
2020-04-13 16:52:38.320 17408-17408/com.example.testvibration W/Create Channel: Default lockscreen: -1000
2020-04-13 16:52:38.321 17408-17408/com.example.testvibration W/Create Channel: Set lockscreen 0
2020-04-13 16:52:49.375 17408-17408/com.example.testvibration W/Print Channel: Get lockscreen -1000
Then I went to System Settings to change the lockscreen visibility to Hide senstitive ....
(private), I got
2020-04-13 16:57:36.180 17408-17408/com.example.testvibration W/Print Channel: Get lockscreen 0
At last I switched back to Show all notification contents
, I got,
2020-04-13 16:59:36.190 15045-15045/com.example.testvibration W/Print Channel: Get lockscreen -1000
So my conclusions are
- you can't really set the lockscreen visibility from code...
- -1000 stands for public
And my question is do we really provide LockScreenVisibility setter for NotificationChannel...
from com.unity.mobile.notifications.
Interesting, thanks for the heads up Vincent!
If I use AndroidNotificationCenter.RegisterNotificationChannel passing a channel where 'LockScreenVisibility' has been seto to 'LockScreenVisibility.Secret', the channel seems to work as intended. I can't see any notification fired on that channel in the lock screen.
from com.unity.mobile.notifications.
So weird... We have tests on NotificationChannel which all the returned value of NotificationChannel.LockscreenVisibility are Public, no matter which value you set on creation. I'm personally testing on Google Pixel 2 with Android 8.
So could you please check what NotificationChannel.LockscreenVisiblity returns for a registered channel? Please use AndroidNotificationCenter.GetNotificationChannel() to retreive the registered channel. I'm expecting it returns Private (which should be Public as I'm going to fix).
Btw, you have to uninstall/reinstall the app to test as you can't change an registered notfication channel from code per Android!
from com.unity.mobile.notifications.
Sorry for the late answer Vincent,
so I have performed the test you asked me. To be clear I am using the version 1.0.3 of the mobile notification package and I am testing on a very old KitKat Android phone.
After registering three different channels with the three different visibility values this is the output:
I/Unity: The visibility for the channel 'game_normal_channel' is: Public
I/Unity: The visibility for the channel 'game_private_channel' is: Private
I/Unity: The visibility for the channel 'game_silent_channel' is: Secret
I confirm that the 'Public' and the 'Secret' channel work just fine while the 'Private' one bahaves like the 'Public' one.
from com.unity.mobile.notifications.
Fixed in 1.2.0-preview.
from com.unity.mobile.notifications.
Related Issues (20)
- Crash: com.unity3d.player.g.onRequestPermissionsResult HOT 5
- ANR in background caused by NotificationCallback.onSentNotification invoking JavaProxy HOT 3
- Notification permission request can be done twice HOT 4
- Native method - android.os.MessageQueue.nativePollOnce Broadcast of Intent { cmp=linkdesks.pop.bubblegames.bubbleshooter/com.unity.androidnotifications.UnityNotificationManager } HOT 7
- UnityNotificationUtilities.deserializeNotificationIntent HOT 1
- AndroidNotificationCenter.UserPermissionToPost does not consider the Status of the notifications from the Android Settings HOT 1
- Automatic permission request on Android 13. HOT 1
- ANR: Broadcast of Intent HOT 3
- [iOS] unregisterForRemoteNotifications ? HOT 1
- 安卓上的崩溃UnityNotificationRestartOnBootReceiver HOT 1
- 请教:如何走到UnityNotificationRestartOnBootReceiver类的onReceive方法 HOT 1
- Consultation: How to go to the onReceive method of the UnityNotificationRestartOnBootReceiver class HOT 1
- [Android] Large Icon is not displayed correctly
- Custom Large and Small icon not show in notification unity android HOT 1
- CancelNotification waits untill all notifications are scheduled before returning HOT 1
- add proguard HOT 1
- Android After I kill the process, there is no notification. HOT 1
- Google Play Rejects Android Apps Using USE_EXACT_ALARM Permission HOT 5
- iOSNotificationCenter.GetLastRespondedNotification() does not work when cold start HOT 9
- Game crashes on IOS after enabling push notifications. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from com.unity.mobile.notifications.