Troubleshooting tips
The following are common troubleshooting tips to follow if you encounter any issues or errors using the Push Notifications SDK.
Some of the troubleshooting tips may make reference to specific common errors. However, even if you don't encounter these issues, it's still recommended to go through them in order.
1. (Android) Verify your Firebase values inside the Push Notifications settings
If you encounter issues while attempting to register your test device to Firebase while using the Push Notification SDK, it's likely that your Firebase values are either empty or invalid.
You can check how to add your Firebase details in the Push Notifications Settings segment.
Alternatively, if you're sure that the values you provided are correct, check there's no whitespace/space after your values. This has been known to cause issues.
2. (EDM4U/MDR) Verify that the dependencies for the Push Notifications SDK have been resolved
Applicable to users integrating the External Dependency Manager for Unity (EDM4U) or the Mobile Dependency Resolver (MDR) alongside Push Notifications.
As noted in the External Dependency Manager for Unity (EDM4U) support section, the Push Notifications SDK doesn't require or bundle the External Dependency Manager for Unity (EDM4U) or the Mobile Dependency Resolver (MDR) to resolve its own dependencies. However, if either is used, the Push Notifications SDK integrates with them.
If you don't require EDM4U or MDR for any other packages, it's recommended you uninstall them.
Otherwise, we recommend you follow these steps:
- Verify that the dependency file
PushSDKDependencies.xml
has been generated. Place this under the auto-generatedAssets/Push Notifications/Editor/Android
directory.- If the file isn't present, re-open your Unity project. The file should be generated as part of this process.
- Use the
Resolve
orForce Resolve
options, both found under Assets -> External Dependency Manager -> Android Manager. - Verify that the Push Notifications SDK's dependencies have been resolved by using the
Display Libraries
option, also found under Assets -> External Dependency Manager -> Android Manager. The following line should appear:implementation 'com.google.firebase:firebase-messaging-ktx:22.0.0' // Assets/Push Notifications/Editor/Android/PushSDKDependencies.xml:9
- Note that the comment besides the above line might be slightly different if other packages or SDKs make use of the same dependency.
3. (Android) Check that Minify isn't excluding the Push Notifications SDK during the build process
If you've gone through the EDM4U / MDR troubleshooting section and still receive something similar to the following error:
java.lang.ClassNotFoundException: com.unity.services.pushnotifications.android.UnityCallbackClass
check your Minify options under Player Settings -> Publishing -> Minify. If the Release
or Debug
checkboxes
are ticked then you're using Minify, which might remove the Push Notifications SDK from the release/debug build as part of the minification process. causing the "class missing" error.
If you don't require Minify, you can turn it off to resolve this issue.
If you want to continue using Minify, you'll need to add the Push Notifications classes under a custom proguard file to prevent the Push Notifications SDK functionality from being excluded during the Minification process.
Enable the Custom Proguard File
under Player Settings -> Publishing -> Build -> Custom Proguard File.
Open the file created under the path specified and append the following line:
-keep class com.unity.services.pushnotifications** { *;}
This should resolve the issue.
4. (iOS) Ensure remote notifications are enabled in XCODE
For iOS apps to be able to receive Push Notifications, Remote Notifications
capabilities need to be granted.
Your app will provide the following error if you fail to do this:
Failed to register for remote notifications: no valid “aps-environment” entitlement string found for application
Go to Signing & Capabilities -> Capability -> Background Modes -> Remote Notifications to provide Remote Notifications
capabilities.
5. Check your API keys in the Unity Dashboard under Push Notifications settings
To send Push Notifications to end-user devices, add your Google and Apple keys to the Unity Dashboard inside Settings
, found under LiveOps -> Push Notifications.
You can find a guide to adding your Google Key here and Apple Key here.
For iOS, ensure your key matches the target build version. For debug builds, set the Sandbox
option to True
, and for production builds, set it to False
. If there's a mismatch between the key and build version, the test device won't receive notifications.
When building your iOS app from the generated XCODE project, you might need to switch the scheme of every target (for example, Unity-iPhone
, notificationservice
) in the run
section from debug
to release
.
if Sandbox
is set to False
, and from release
to debug
if Sandbox
is set to True
.
Check your keys work by using the testing guide.