Skip to content

Troubleshooting

Nate River edited this page Sep 25, 2023 · 43 revisions

Before you start troubleshooting (believe me, these steps can save a lot of your and my time!)

  • Update Android SDK to the latest version.
  • Update Unity to the latest version (LTS is prefered).
  • Create a new empty project in Unity.
  • Download and import the latest asset version from the Asset Store.
  • Build demo scene as SimpleAndroidNotifications.apk and install it on your device.
  • Open Applications from System Settings, make sure that notifications are enabled for Simple Android Notifications app.
  • Open Energy Saving settings (depends on the device) and make sure that Energy Saving is disabled.
  • Run Simple Android Notifications app.
  • Press Simple in 5s button. If notification is shown - that's great!
  • If notification was not shown, the first thing I would recommend you is to try the steps on another device.

Common problems: notifications are not showing, manifest conflicts, unexpected behavior, the app is not launching from notification

  • It’s very important to check if the problem relates either to my plugin or to your project setup. Please refer to clean setup to make sure that plugin works! Create new Unity project, then import plugin, build demo scene and test notifications on device.
  • You can also try to set code Minimizer to None from Build Settings (or refer Building with Gradle minimizer section).
  • Some custom shells like MIUI can block notifications by aggressive memory management, check this article How to fix MIUI push notifications or similar for your manufacturer.

Your app does not launch on clicking the notification?

  • Seems that you need to check Unity activity name in your app manifest (Plugins/Android/AndroidManifest.xml). It must be UnityPlayerActivity. If you define another activity name (i.e. UnityPlayerNativeActivity that is obsolete), you must change this constant from NotificationManager:

private const string MainActivityClassName = "com.unity3d.player.UnityPlayerActivity";

Notifications are still not working?

  • Resolution: make sure notifications are enabled in your app settings because notifications are disabled by default on some devices (especially with custom shells).
  • Android 13 requires "android.permission.POST_NOTIFICATIONS" to show notifications. You can only ask for this permission when you Target API Level >= 33. When your app targets lower SDK, OS asks for permission automatically, your app can't do that, best it can do is to open the settings page for itself.
  • Notifications can be blocked on Huawei, Xiaomi and other devices due to their aggressive memory management and custom Android tweaks. Huawei - Go to Settings > "Protected apps", check your app. Xiaomi - Make sure that "Auto-start" property is enabled for your app in power settings and activity control is disabled for your app.

Can't change notification settings on Android 8 and later (sound, vibration, lighting)

Notes: in Android API 26 (Oreo) notification sounds are moved to channels. After a new channel is created, it will be displayed in the app’s notification settings. All channel settings (including custom sound) should be defined while creating a new channel. There is no way to change channel’s settings (including custom sound), except reinstalling the app. (https://developer.android.com/training/notify-user/channels)

Workaround: delete and create the channel again. Use NotificationManager.GetNotificationChannelIds() and NotificationManager.DeleteNotificationChannel(channelId).

Moreover, custom UI like Xiaomi MIUI may override notifications behaviour. For example, all new notifications in Xiaomi Mi Pad are muted by default. You can't change it by deleting channels or by reinstalling the app. The only way is to ask user to change it manually. More info: https://www.reddit.com/r/Xiaomi/comments/906p09/notification_sounds_not_working_on_miui_10_8719/

Building with Gradle minimizer

  • Add this to proguard-user file:

-keep class com.hippogames.simpleandroidnotifications.* { *; }

Can’t add custom icon, error with archive? (paid version)

  • Resolution: use Windows instead of Mac OS, because Mac OS adds hidden files and creates incorrect new archive. I would recommend you to use Total Commander for this task. Please refer to plugin manual for more details.

Issues with displaying?

  • Please note, that custom shells (like MUI, ZUI) may display notifications not as they should be displayed on clean Android.

This FAQ didn't help me =(

I've found a bug!