Giter Club home page Giter Club logo

com.unity.mobile.notifications's Introduction

Mobile Notifications Package

Note: Please report issues via Unity bug tracker rather than creating issues on github, then we can have QA to follow and verify the bugs and fixes. To see how to use Unity bug tracker, read this.

com.unity.mobile.notifications's People

Contributors

alexey-unity avatar allan-o3h avatar anjalin14 avatar aurimasc avatar etherelric avatar irunn3r avatar itsneil avatar jcmvenom avatar johnsympatient avatar jpriyas avatar kernalpanik avatar manugildev avatar ondrowan avatar renaldasrep avatar rocksteadydog avatar serefbulbul avatar todi1856 avatar vaidas-unity avatar vaidasma avatar vincent-unity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

com.unity.mobile.notifications's Issues

This line seems to be throwing exception for Arabic users

int id = Math.Abs(DateTime.Now.ToString("yyMMddHHmmssffffff").GetHashCode()) + (new System.Random().Next(10000));

`Non-fatal Exception: java.lang.Exception
ArgumentOutOfRangeException : Not a valid calendar for the given culture. Parameter name: value

System.Globalization.DateTimeFormatInfo.set_Calendar (System.Globalization.DateTimeFormatInfo)
System.Globalization.CultureInfo.get_DateTimeFormat (System.Globalization.CultureInfo)
System.Globalization.CultureInfo.GetFormat (System.Globalization.CultureInfo)
System.Globalization.DateTimeFormatInfo.get_CurrentInfo (System.Globalization.DateTimeFormatInfo)
System.DateTime.ToString (System.DateTime)
Unity.Notifications.Android.AndroidNotificationCenter.SendNotification (Unity.Notifications.Android.AndroidNotificationCenter)`

PLEASE READ BEFORE POSTING ANY ISSUES

We kindly ask you to send us issues via Unity's bug reporter (In editor: Help > Report a Bug), as it comes with additional information about your machine and Unity editor's release, as well as the fact that our customer support is actively working to process them, which is not always the case with GitHub.

In case, for some reason, you are still compelled to post here, in order for the report to be effective, please include essential information so it would be easier for us to understand your issue:

• Project that reproduces the issue
• Android / iOS issue
• Notification Package version, that you are using
• Unity editor's version, that you are using
• Mobile devices and their OS, that reproduce the issue

Best regards!

EndOfStreamExeception Error On IOS and Android

Hi, I'm using GameNotificationManager in my scripts but got some errors about file reading. I chose "Clear On Foregrounding" on GameNotificationManager component. I can't reproduce error, only one of my colleagues has got this error once. But we are get lot of logs from analytics about that.

Unity Version: 2020.3.27f1

Mobile Notifications Version: 1.4.2

Error :
System.IO.__Error.EndOfFile () (at <00000000000000000000000000000000>:0)
System.IO.BinaryReader.ReadByte () (at <00000000000000000000000000000000>:0)
NotificationSamples.DefaultSerializer.Deserialize (NotificationSamples.IGameNotificationsPlatform platform) (at <00000000000000000000000000000000>:0)
NotificationSamples.GameNotificationsManager.OnForegrounding () (at <00000000000000000000000000000000>:0)
NotificationSamples.GameNotificationsManager.OnApplicationFocus (System.Boolean hasFocus) (at <00000000000000000000000000000000>:0)

[Feature Request] Сhange notification icons in the editor via code

Hello!

Сhange notification icons in the editor via code

For example:
Unity.Notifications.NotificationSettings.AndroidSettings.AddOrReplaceIcon("ic_test_0",Size.Small, new Texture2D(...)); Unity.Notifications.NotificationSettings.AndroidSettings.AddOrReplaceIcon("ic_test_1", Size.Large, new Texture2D(...));

Unity.Notifications.NotificationSettings.AndroidSettingsю.ClearAllIcons();


if there are many different projects in one project, then solution is to create different files for each project during the project build

For example:

Build Project A

Create
\Assets\Plugins\Android\res\drawable\ic_project_a_small
\Assets\Plugins\Android\res\drawable\ic_project_a_large

Delete
{Assets\Plugins\Android\res\drawable\ic_project_b_small
\Assets\Plugins\Android\res\drawable\ic_project_b_large

Build Project B...

Create
\Assets\Plugins\Android\res\drawable\ic_project_b_small
\Assets\Plugins\Android\res\drawable\ic_project_b_large

Delete
{Assets\Plugins\Android\res\drawable\ic_project_a_small
\Assets\Plugins\Android\res\drawable\ic_project_a_large

Screenshot_3

[Feature] Please add a way to open the OS Notification Settings.

Hi folks,

I'm using your package in my game and I can't find a way to prompt the Notification Settings ( on Android open the Notification Settings Activity, and on iOS the URL that I will open with Application.OpenURL).
In my case, the user can check if the notification is enabled on the Settings menu and click on the button to enable it, but the only way to do it, so far, is creating a custom Unity Plug-in, so all I'm asking is to add support for opening the native Notification Settings in your package.

Cheers

iOS Notification received callback

UnityMobileNotification 1.3.0
Unity: 2019.2.17f1
Platerform: iOS

Hi, the callback iOSNotificationCenter.OnNotificationReceived doesn't work, in foreground or background.
Do you have an idea ?

Best regards

Custom background image for android notification

Is there a way to customise notification background image (notification type big picture style) in Unity mobile notification, currently the notification comes with a white background. As I know there is a support for this in native android. Is there a provision for this in unity mobile notification

Badge count, how is it supposed to work?

I've read all the warning signs but posting here anyway because it's not really a bug report; more of a question regarding intended functionality.

I implemented the notifications package (1.4.2) in our project and noticed the following:

When I schedule a local notification on iOS, I set the Badge property to 1 because I want the badge counter to increase by 1. However, it seems to me that the badge counter is not incremented by the value, it's actually just set to the exact value specified. Regardless of how many notifications are triggered, my badge counter always stays at 1 until I clear all the notifications.

This basically makes it impossible to set a meaningful badge number, since I can't possibly know beforehand how many unhandled notifications the user will have at the time when the notification will trigger.

Pretty sure it works by incrementing on Android though, but not able to confirm at the moment as I don't have access to an Android device.

Is this really the intended behaviour? OS limitation? Or am I just missing something here?

[Android] Bad notification posted from package com.***: Couldn't create icon: StatusBarIcon

Plugin v1.5.0
Unity v2020.3.25f1

Sometimes the following exception has occurred:
`Fatal Exception: java.lang.Error: FATAL EXCEPTION [main]

Caused by android.app.RemoteServiceException: Bad notification posted from package com.*** : Couldn't create icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.*** id=0x7f080102) visible user=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1802)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)`

Some thoughts on the reason for this exception.

Custom layout for Android?

A lot of games on Android have great notifications with custom layout. I would like to add that to my notifications as well, but as far as I am concerned there is no option for that, I saw that custom sounds was planned to be done for Mobile Notifications Plugin (there was a TO DO comment in source code), but 2 years later it was never added.

Android 12 bug. version 2.0.0 not working

Fatal Exception: java.lang.RuntimeException
Unable to start receiver com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver: java.lang.IllegalArgumentException: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles

Please fix this issue.
Thanks advance

RenderTexture creation failed. 'Default' is not supported on this platform

Hi,

I see this error while building on Android platform:

RenderTexture creation failed. 'Default' is not supported on this platform. Use 'SystemInfo.SupportsRenderTextureFormat' C# API to check format support.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object, Object)
UnityEngine.Debug:LogError(Object, Object)
UnityEngine.Texture:ValidateFormat(RenderTextureFormat) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Texture.cs:347)
UnityEngine.RenderTexture:.ctor(Int32, Int32, Int32, RenderTextureFormat, RenderTextureReadWrite) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Texture.cs:152)
UnityEngine.RenderTexture:.ctor(Int32, Int32, Int32) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Texture.cs:170)
Unity.Notifications.TextureAssetUtils:ScaleTexture(Texture2D, Int32, Int32) (at Library/PackageCache/[email protected]/Editor/UnityNotificationEditorManager.cs:682)
Unity.Notifications.UnityNotificationEditorManager:GenerateDrawableResourcesForExport() (at Library/PackageCache/[email protected]/Editor/UnityNotificationEditorManager.cs:558)
Unity.Notifications.AndroidNotificationResourcesPostProcessor:OnPostGenerateGradleAndroidProject(String) (at Library/PackageCache/[email protected]/Editor/UnityNotificationEditorManager.cs:778)
UnityEditor.Android.AndroidBuildPipelineInterfaces:OnGeneratePlatformProjectPostprocess(String, Boolean) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Android/AndroidPostGenerateGradleProject.cs:39

)

After successfully build APK file, when testing notification on Android device I see that the icon is blank white, I guess it relates to this issue.

How can I fix it? Thanks.

Unity 2018.4.20f1
Mobile Notifications 1.0.3

MacBook Pro (Retina, 13-inch, Late 2013)
Processor 2.4 GHz Dual-Core Intel Core i5
Memory 8 GB 1600 MHz DDR3
Graphics Intel Iris 1536 MB

1.5.0 tag missing

1.5.0 was created as branch and merged into master. But the tag is missing. It is also not yet in Unity Package Manager. Is that on purpose?

Safer component exporting

Hi,
I'm developing Android app for Android12 now but build goes failed. It seem you need to add [android:exported] attribute for all components like here.
It look there is undeclared component added by AndroidNotificationPostProcessor.cs in latest package.

            // Create notification restart-on-boot receiver if necessary.
            if (notificationRestartOnBootReceiver == null)
            {
                notificationRestartOnBootReceiver = manifestXmlDoc.CreateElement("receiver");
                notificationRestartOnBootReceiver.SetAttribute("name", kAndroidNamespaceURI, kNotificationRestartOnBootName);

                var intentFilterNode = manifestXmlDoc.CreateElement("intent-filter");

                var actionNode = manifestXmlDoc.CreateElement("action");
                actionNode.SetAttribute("name", kAndroidNamespaceURI, "android.intent.action.BOOT_COMPLETED");

                intentFilterNode.AppendChild(actionNode);
                notificationRestartOnBootReceiver.AppendChild(intentFilterNode);
                applicationXmlNode.AppendChild(notificationRestartOnBootReceiver);
            }
            notificationRestartOnBootReceiver.SetAttribute("enabled", kAndroidNamespaceURI, "false");
           notificationRestartOnBootReceiver.SetAttribute("exported", kAndroidNamespaceURI, "true"); //I added attribute here
        }

After I fixed here I have succeed to build the app, could you check for them?

Thank you.

Critical error in reading userInfo from received notification on iOS produces a crash

When iOS Notification has been received this library deserialise it's userInfo content using iOS internal NSJSONSerialization function. This all happens in UnityNotificationData.mm in _ReadNSDictionary function.

During iterating of userInfo this function assumes that values can be only strings or json objects. This is incorrect as userInfo is created from ordinary json payload passed to APS and lead to a crash if values other than string or object are placed in payload.

As Apple's doc states:

Your custom keys must have values with primitive types, such as dictionary, array, string, number, or Boolean. Custom keys are available in the userInfo dictionary of the UNNotificationContent object delivered to your app.

Currently passing any value other than string or object to userInfo payload produces a crash. Example:

{"t":"b","i":110,"aps":{"alert":{"body":"[stage] Test"},"badge":1,"content-available":1}}

In this example "t":"b" is deserialised ok but "i":110 produces a crash.

As far as i can see this has not been fixed in current master.

--

Workaround for now - use only string or object values for payload to avoid a crash

[Android ANR] Caused by blocking main thread when cancellation notifications

Simply Generate 50-100 Notifications, When you call AndroidNotificationCenter.CancelAllNotifications this will cause an ANR because all the logic is handled on the main thread. This is especially worst when you call this function in the application resume state

public static void CancelAllNotifications()
{
if (!Initialize())
return;
CancelAllScheduledNotifications();
CancelAllDisplayedNotifications();

These calls should be handled inside a thread and can be changed to async Task.

AuthorizationRequest bug

Added an event listener to the constructor, but forgot to release it into the event listener in Dispose

public AuthorizationRequest(AuthorizationOption authorizationOption, bool registerForRemoteNotifications) { ... iOSNotificationCenter.OnAuthorizationRequestCompleted += data => ... }

public void Dispose() { }

Can not publish on google play store

When use Notification pakage there is this error when uploaded to google play store.

You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set. This file can't be installed on Android 12 or higher. See: developer.android.com/about/versions/12/behavior-changes-12#exported"

I hope you could release this change as verified pakage soon.

[Bug] Unity Editor resets Notification config

I'm setting notification settings via the editor config page (Project Settings -> Mobile Notification), but sometimes after a build, all settings are reset to the default values, like when the asset is freshly installed.

I'm still not sure when exactly this is happening, but maybe it's already a known issue?

Unity Editor: version 2020.3.22f (also happens with previous 2020 versions)
Mobile Notification: version 1.4.2

[Android] java.lang.NullPointerException in UnityNotificationRestartOnBootReceiver.java

Unity v2020.3.25f1
Plugin v1.5.0

`Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Parcelable android.content.Intent.getParcelableExtra(java.lang.String)' on a null object reference
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4125)
at android.app.ActivityThread.access$1400(ActivityThread.java:270)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2062)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Parcelable android.content.Intent.getParcelableExtra(java.lang.String)' on a null object reference
at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive(UnityNotificationRestartOnBootReceiver.java:26)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4116)
at android.app.ActivityThread.access$1400(ActivityThread.java:270)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2062)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)`

data_intent can be null in saved_notifications List

The approach used in cancel all notification should be optimized

public void cancelAllPendingNotificationIntents() {
int[] ids = this.getScheduledNotificationIDs();
for (int id : ids) {
cancelPendingNotificationIntent(id);
}
}

The way the cancellation of all the notifications is handled is not optimized, Instead of looping through all the notifications and modifying the player prefs for in each notification, The player prefs usage can be optimized to just remove the key or empty it once the cancellation is complete

This code is redundant in case of cancel all notification

// Cancel a pending notification by id.
protected static synchronized void cancelPendingNotificationIntent(Context context, int id) {
Intent intent = new Intent(context, UnityNotificationManager.class);
PendingIntent broadcast = getBroadcastPendingIntent(context, id, intent, PendingIntent.FLAG_NO_CREATE);
if (broadcast != null) {
if (context != null) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(broadcast);
}
broadcast.cancel();
}
SharedPreferences prefs = context.getSharedPreferences(NOTIFICATION_IDS_SHARED_PREFS, Context.MODE_PRIVATE);
Set<String> ids = new HashSet<String>(prefs.getStringSet(NOTIFICATION_IDS_SHARED_PREFS_KEY, new HashSet<String>()));
String idStr = Integer.toString(id);
if (ids.contains(idStr)) {
ids.remove(Integer.toString(id));
SharedPreferences.Editor editor = prefs.edit().clear();
editor.putStringSet(NOTIFICATION_IDS_SHARED_PREFS_KEY, ids);
editor.apply();
}
}

iOS 15 app crashes on getPendingNotificationRequestsWithCompletionHandler

Hi, Unity Team!

We detected app crash because of calling getPendingNotificationRequestsWithCompletionHandler method.
We made fast fix because we can't stop development process, but this issues should be critical for all users.
Hope, you will fix this soon.

Our fix:

- (void)updateScheduledNotificationList
{
    UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
    static dispatch_once_t onceToken_2 = 2;
    dispatch_once(&onceToken_2, ^{
        [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
            self.cachedPendingNotificationRequests = requests;
        }];
    }];
}

Can't set iOS Foreground Presentation Options to "Nothing"

Even with my Unity app in foreground, iOS notifications (sent from Firebase) were shown from the tray (in addition to my app handling them anyway). I found the global project setting "Remote Notification Foreground Presentation Options" that seem to do the trick of letting me choose how to handle the tray presentation. I would like to set it to "Nothing", but that doesn't work. It then instantly sets it back to "All". Currently I've set it to only "Sound", which at least just leaves me with the still annoying beep only. How can I suppress any notification handling outside of the running app?
I am using Mobile Notifications package 1.0.3.

AndroidNotificationChannel.LockScreenVisibility.Private not working

Hello guys, while testing the lock screen visibility levels on Android I realised the 'Private' level doesn't seem to work.

Looking into the source it seems that 'AndroidNotificationChannel.LockScreenVisibility' enum sets the 'Private' label equal to '-1000'.

However according to Android documentation the value for the 'private' state of the lock screen visibility is 0 (0x00000000).

Delayed Application Launch When Package Present - iOS

We have an external package which is timing sensitive. It appears when the Mobile Notifications package is present in our iOS builds, we are hitting a race condition due to the presence of the Mobile Notifications package.

IOS Location Notifications not working - repro'd with Xcode Sim and the test project

Reported in Unity Bug Report Case 1350063 after pulling the test project from github and trying to get the location triggers to work from there. It seems there is a test location notification button that just sets up a location notification at lat/long 0/0 which does absolutely nothing, when changing that to my location or London/Tokyo which can be simulated in Xcode with a reasonable radius and simulating the location in Xcode after both in and out, the notifications do not fire.

This is using Xcode > Debug > Simulate Location options when launching the app from Xcode.

As far as I can see this functionality is totally not working and we need it for a current project. Is there anyone who can look into this? I don't understand why the test project in the repo is showing it not working too, isn't the test project there so that it can be verified as working? I hope it is just me missing something small.

[Android] How can i get delivered push notification after launch by app, not the push notification.

Good day everyone!

[Android] How can i get delivered push notification after the launch app, not after click on the push notification.
In iOS I can get it like that:

`Good day everyone!

[Android] How can i get delivered push notification after the launch app, not after click on the push notification.
In iOS I can get it like that:

**private void IOSGetLastRespondedNotification()
{
    iOSNotification notification = null;

    if (iOSNotificationCenter.GetLastRespondedNotification() != null)
    {
        notification = iOSNotificationCenter.GetLastRespondedNotification();
    } 
    else if (iOSNotificationCenter.GetDeliveredNotifications() != null &&
             iOSNotificationCenter.GetDeliveredNotifications().Length > 0)
    {
        notification = iOSNotificationCenter.GetDeliveredNotifications().Last();
    }

    if (notification != null)
    {
        HandleIOSRespondedNotification(notification);
    }
}**

But in Android I can use only this:
var notificationIntentData = AndroidNotificationCenter.GetLastNotificationIntent();

The scenario:

  1. Send push.
  2. Receive push.
  3. Open app by icon.
  4. Android say no anything, but iOS get last push notification and handled it.

[Android] java.lang.NoSuchMethodError in UnityNotificationRestartOnBootReceiver.java

Unity v2020.3.25f1
Plugin v1.5.0

The plugin is not working on Android 6.0 and less.

Fatal Exception: java.lang.NoSuchMethodError: No static method recoverBuilder(Landroid/content/Context;Landroid/app/Notification;)Landroid/app/Notification$Builder; in class Landroid/app/Notification$Builder; or its super classes (declaration of 'android.app.Notification$Builder' appears in /system/framework/framework.jar) at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive(UnityNotificationRestartOnBootReceiver.java:43) at android.app.ActivityThread.handleReceiver(ActivityThread.java:2921) at android.app.ActivityThread.access$1800(ActivityThread.java:179) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1576) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5765) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

This is because of Notification.Builder.recoverBuilder method is used in UnityNotificationRestartOnBootReceiver.java and this method was added in API 24.

[Android] java.lang.OutOfMemoryError on Android 12

Unity: v2020.3.26f1
Plugin: 19a3d9d4f064d1f814138aedc5dc1ffa061cb3a8

java.lang.OutOfMemoryError: 
  at android.os.Parcel.createString8Array (Parcel.java:1489)
  at android.content.pm.ApplicationInfo.<init> (ApplicationInfo.java:1999)
  at android.content.pm.ApplicationInfo.<init> (ApplicationInfo.java:62)
  at android.content.pm.ApplicationInfo$1.lambda$createFromParcel$0 (ApplicationInfo.java:1968)
  at android.content.pm.ApplicationInfo$1$$ExternalSyntheticLambda0.readRawParceled (Unknown Source)
  at android.os.Parcel.readSquashed (Parcel.java:2134)
  at android.content.pm.ApplicationInfo$1.createFromParcel (ApplicationInfo.java:1968)
  at android.content.pm.ApplicationInfo$1.createFromParcel (ApplicationInfo.java:1965)
  at android.os.Parcel.readParcelable (Parcel.java:3345)
  at android.os.Parcel.readValue (Parcel.java:3238)
  at android.os.Parcel.readArrayMapInternal (Parcel.java:3635)
  at android.os.BaseBundle.initializeFromParcelLocked (BaseBundle.java:292)
  at android.os.BaseBundle.unparcel (BaseBundle.java:236)
  at android.os.BaseBundle.getString (BaseBundle.java:1196)
  at com.unity.androidnotifications.UnityNotificationUtilities.deserializeNotificationCustom (UnityNotificationUtilities.java:300)
  at com.unity.androidnotifications.UnityNotificationUtilities.deserializeNotificationIntent (UnityNotificationUtilities.java:219)
  at com.unity.androidnotifications.UnityNotificationUtilities.deserializeNotificationIntent (UnityNotificationUtilities.java:206)
  at com.unity.androidnotifications.UnityNotificationManager.loadNotificationIntents (UnityNotificationManager.java:429)
  at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive (UnityNotificationRestartOnBootReceiver.java:23)
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:4763)
  at android.app.ActivityThread.access$1700 (ActivityThread.java:310)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2294)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8641)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:567)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1133)

The exception occurred on different user devices with Android 12 only

The big icon size used for the notification is 256x256 32bpp

Missing "exported" attributed in manifest while generating APK

After the Behavior changes in Android, If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the "android: exported" attribute for these app components.

This is not happening right now, failing when the apk is uploaded to android. This attribute should be added into the manifest when it is generated in the class "AndroidNotificationPostProcessor" line 118 approx.

https://developer.android.com/about/versions/12/behavior-changes-12#exported

Is happening in Android, Unity 2020.3.20f, "Mobile notification package" version 1.4.2 ( the last when this was written )

[Android] Doesn't work with android 12

The package does not work with android 12. When trying to install APK, it gives an error: "There was a problem parsing the package". Also does not work when trying to download from Google play. I spent a couple of days trying to find out what the issue is. When I removed this package, everything worked. The error only appears with android SDK 31. App works with android SDK 30 but not correctly.

Unity version: 2020.3.23f1
Unity Mobile Notifications 1.4.2
Platform: Android
Platform OS version: Android 12
Any specific devices issue occurs on: Google Pixel 4(Android 12)

How do I schedule a repeat notification with the sample code?

I took a look and see there are so many functions built in the sample notification script GameNotificationsManager and their relevant components. But I don't see how to schedule a repeating notification. Is it possible or do I have to write my own code?

After entering and exiting play mode, trying to add new icon in Project Settings > Mobile Notifications results in ArgumentNullException error

ArgumentNullException: Value cannot be null.
Parameter name: identifier
UnityEditor.Undo.RegisterCompleteObjectUndo (UnityEngine.Object objectToUndo, System.String name) (at /Users/bokken/buildslave/unity/build/Editor/Mono/Undo/Undo.bindings.cs:63)
Unity.Notifications.NotificationSettingsProvider.b__17_0 (UnityEditorInternal.ReorderableList list) (at /Users/vaidasm/Documents/GitHub/com.unity.mobile.notifications/com.unity.mobile.notifications/Editor/NotificationSettingsProvider.cs:81)
UnityEditorInternal.ReorderableList+Defaults.DrawFooter (UnityEngine.Rect rect, UnityEditorInternal.ReorderableList list) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:185)
UnityEditorInternal.ReorderableList.DoListFooter (UnityEngine.Rect footerRect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:990)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:686)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:668)
Unity.Notifications.NotificationSettingsProvider.OnGUI (System.String searchContext) (at /Users/vaidasm/Documents/GitHub/com.unity.mobile.notifications/com.unity.mobile.notifications/Editor/NotificationSettingsProvider.cs:244)
UnityEditor.SettingsWindow.DrawControls () (at /Users/bokken/buildslave/unity/build/Editor/Mono/Settings/SettingsWindow.cs:407)
UnityEditor.SettingsWindow.DrawSettingsPanel () (at /Users/bokken/buildslave/unity/build/Editor/Mono/Settings/SettingsWindow.cs:385)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:353)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:663)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:635)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:628)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:594)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:583)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/IMGUIContainer.cs:516)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Events/EventHandler.cs:125)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Events/MouseCaptureDispatchingStrategy.cs:83)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:373)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:336)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:299)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:264)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:75)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:364)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/EventDispatcher.cs:216)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/Panel.cs:371)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:461)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:209)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:74)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Core/UIElementsUtility.cs:28)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

[Android] java.lang.RuntimeException: invalid Icon type in parcel

Plugin v1.5.0
Unity v2020.3.26f1 il2cpp build

`Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver: java.lang.RuntimeException: invalid Icon type in parcel: 13
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4772)
at android.app.ActivityThread.access$1800(ActivityThread.java:310)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2294)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8641)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)

Caused by java.lang.RuntimeException: invalid Icon type in parcel: 13
at android.graphics.drawable.Icon.(Icon.java:903)
at android.graphics.drawable.Icon.(Icon.java:71)
at android.graphics.drawable.Icon$1.createFromParcel(Icon.java:945)
at android.graphics.drawable.Icon$1.createFromParcel(Icon.java:943)
at android.app.Notification$Action.(Notification.java:1731)
at android.app.Notification$Action.(Notification.java:1607)
at android.app.Notification$Action$1.createFromParcel(Notification.java:2134)
at android.app.Notification$Action$1.createFromParcel(Notification.java:2132)
at android.os.Parcel.readTypedObject(Parcel.java:3183)
at android.os.Parcel.createTypedArray(Parcel.java:3144)
at android.app.Notification.readFromParcelImpl(Notification.java:2572)
at android.app.Notification.(Notification.java:2498)
at android.app.Notification$1.createFromParcel(Notification.java:3218)
at android.app.Notification$1.createFromParcel(Notification.java:3215)
at android.os.Parcel.readParcelable(Parcel.java:3345)
at android.os.Parcel.readValue(Parcel.java:3238)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3635)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
at android.os.BaseBundle.unparcel(BaseBundle.java:236)
at android.os.Bundle.getParcelable(Bundle.java:1002)
at android.content.Intent.getParcelableExtra(Intent.java:9180)
at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive(UnityNotificationRestartOnBootReceiver.java:26)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4763)
at android.app.ActivityThread.access$1800(ActivityThread.java:310)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2294)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8641)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)`

There are a lot of exceptions for different Android versions

Implicit PendingIntent Vulnerability

Hi,

Looks like after we have integrated Mobile Notifications 1.3.2 we received an e-mail from the Google:

Your app(s) contain an Implicit PendingIntent issue.
To address this issue, follow the steps in this Google Help Center article.

I see that you do not use FLAG_IMMUTABLE in the package. Can it be the problem?

Thank you.

Upgrading Unity to 2019.2.12f1 Caused Java Exception <NoSuchMethodError>

Everything was working until we upgraded Unity to 2019.2.12f1 yesterday.

We use our own activity wrapper

Have encountered this problem with Android version 7-10

Using package version 1.0.3

100% reproducible

Here's the error:

11-19 11:45:27.774 30130 30198 E Unity : LuaExceptionWithStackTrace: c# exception:UnityEngine.AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='findResourceidInContextByName' signature='(Ljava/lang/String;Landroid.app.Application;Lcom.wildsky.plugin.UnityActivityWrapper;)I' in class Lcom.unity.androidnotifications.UnityNotificationManagerOreo;
11-19 11:45:27.774 30130 30198 E Unity : at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
11-19 11:45:27.774 30130 30198 E Unity : at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <00000000000000000000000000000000>:0
11-19 11:45:27.774 30130 30198 E Unity : at UnityEngine.AndroidReflection.GetMethodMember (System.IntPtr jclass, System.String methodName, System.String signature, System.Boolean isStatic) [0x00000] in <00000000000000000000000000000000>:0
11-19 11:45:27.774 30130 30198 E Unity : at UnityEngine._AndroidJNIHelper.GetMethodID (System.IntPtr jclass, System.String methodName, System.String signature, System.Boolean isStatic) [0x00000] in <00000000000000000000000000000000>:0
11-19 11:45:27.774 30130 30198 E Unity : at UnityE
11-19 11:45:39.542 30489 30556 I Unity : SystemInfo CPU = ARM64 FP ASIMD AES, Cores = 8, Memory = 3656mb
11-19 11:45:39.542 30489 30556 I Unity : SystemInfo ARM big.LITTLE configuration: 4 big (mask: 0xf0), 4 little (mask: 0xf)
11-19 11:45:39.543 30489 30556 I Unity : ApplicationInfo com.wildsky.td version 1.6.14 build a0fcd094-d663-4b71-b165-ac247da8ea9d
11-19 11:45:39.543 30489 30556 I Unity : Built from '2019.2/staging' branch, Version '2019.2.12f1 (b1a7e1fb4fa5)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a', Stripping 'Enabled'
11-19 11:45:39.874 30489 30556 D Unity : GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_vertex_half_float GL_OES_framebuffer_object GL_OES_rgb8_rgba8 GL_OES_compressed_ETC1_RGB8_texture GL_AMD_compressed_ATC_texture GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_OES_texture_compression_astc GL_OES_texture_npot GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_read_format_bgra GL_OES_texture_3D GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_QCOM_alpha_test GL_OES_depth24 GL_OES_packed_depth_stencil GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_EXT_sRGB GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_EXT_texture_type_2_10_10_10_REV GL_EXT_texture_sRGB_decode GL_EXT_texture_format_sRGB_override GL_OES_element_index_uint GL_EXT_copy_image GL_EXT_geometry_shader GL_EXT_tessellation_shader GL_OES_texture_stencil8 GL_EXT_shader_io_blocks GL_OES_shader_image_atomic GL_OES_sample_variables GL_EXT_texture_b
11-19 11:45:39.874 30489 30556 D Unity : order_clamp GL_EXT_EGL_image_external_wrap_modes GL_EXT_multisampled_render_to_texture GL_EXT_multisampled_render_to_texture2 GL_OES_shader_multisample_interpolation GL_EXT_texture_cube_map_array GL_EXT_draw_buffers_indexed GL_EXT_gpu_shader5 GL_EXT_robustness GL_EXT_texture_buffer GL_EXT_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_OES_texture_storage_multisample_2d_array GL_OES_sample_shading GL_OES_get_program_binary GL_EXT_debug_label GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_QCOM_tiled_rendering GL_ANDROID_extension_pack_es31a GL_EXT_primitive_bounding_box GL_OES_standard_derivatives GL_OES_vertex_array_object GL_EXT_disjoint_timer_query GL_KHR_debug GL_EXT_YUV_target GL_EXT_sRGB_write_control GL_EXT_texture_norm16 GL_EXT_discard_framebuffer GL_OES_surfaceless_context GL_OVR_multiview GL_OVR_multiview2 GL_EXT_texture_sRGB_R8 GL_KHR_no_error GL_EXT_debug_marker GL_OES_EGL_image_external_essl3 GL_OVR_multiview_multisampled_render_to_texture GL_E
11-19 11:45:39.874 30489 30556 D Unity : XT_buffer_storage GL_EXT_external_buffer GL_EXT_blit_framebuffer_params GL_EXT_clip_cull_distance GL_EXT_protected_textures GL_EXT_shader_non_constant_global_initializers GL_QCOM_texture_foveated GL_QCOM_shader_framebuffer_fetch_noncoherent GL_QCOM_shader_framebuffer_fetch_rate GL_EXT_memory_object GL_EXT_memory_object_fd GL_EXT_EGL_image_array GL_NV_shader_noperspective_interpolation GL_KHR_robust_buffer_access_behavior GL_EXT_EGL_image_storage GL_EXT_blend_func_extended GL_EXT_clip_control GL_OES_texture_view GL_EXT_fragment_invocation_density
11-19 11:45:40.230 30489 30556 I Unity : UnityEngine.Scripting.GarbageCollector.isIncremental = True

Incompatible with GooglePlayResolver (External Dependency Manager)

Because you now have .java files directly in this package. External Dependency Manager will not detect duplicate uses and the build will have issues due to conflicting api functions.

The Resolver is pretty much essential in any project so support should be prioritized.

I dont think there is a work around currently that I know of so I am downgrading to a previous version.

AuthorizationRequest never finishes when authorization is granted

I'm having an issue getting 1.0.3 to work for iOS.
Running the following code

        System.Collections.IEnumerator RequestAuthorization(System.Action callback)
        {
            using (var req = new AuthorizationRequest(AuthorizationOption.Alert | AuthorizationOption.Badge | AuthorizationOption.Sound, true))
            {
                while (!req.IsFinished)
                {
                    string res2 = "\n RequestAuthorization: \n";
                    res2 += "\n finished: " + req.IsFinished;
                    res2 += "\n granted :  " + req.Granted;
                    res2 += "\n error:  " + req.Error;
                    res2 += "\n deviceToken:  " + req.DeviceToken;
                    Debug.LogError(res2);
                    yield return null;
                };

                string res = "\n RequestAuthorization: \n";
                res += "\n finished: " + req.IsFinished;
                res += "\n granted :  " + req.Granted;
                res += "\n error:  " + req.Error;
                res += "\n deviceToken:  " + req.DeviceToken;
                Debug.LogError(res);

                callback?.Invoke();
            }
        }

Produces the following result:

  1. First startup, prompts me to approve notifications which I do.
    req.IsFinished never becomes true and req.Granted is false. Error and DeviceToken is blank.

  2. Second startup, no prompt since notifications have already been approved.
    req.IsFinished never becomes true and req.Granted is false. Error and DeviceToken is blank.

  3. Disallow notifications in the devices settings for the app. No prompt.
    This time req.IsFinished becomes true and req.Granted is false. Error and DeviceToken is blank.

Is there a bug somewhere or am I missing some crucial step in setting up notifications for iOS?
Tried with both Request Authorization on App Launch on and off, and Enable Push Notifications on and off. We have previously used Push Notifications through another third-party API.

AuthorizationRequest never completes on iOS 14 on package version 1.3.2

Hi, Im just implementing this package (migrating from using UnityEngine.iOS.NotificationServices.deviceToken) on a live game, notifications permissions are added at certain point in the game, and players might already accepted in a previous version.

We have other plugins and one of them handles the System permission request.

We have the iOS settings:

  • Enable Push Notifications = TRUE
  • Register for Push Notifications on App Launch = FALSE.
  • Enable Release Environment for APS = TRUE
  • Include CodeLocation Framework = TRUE

The code used at the start of the game is:

private void InitializeiOSPushTokenIfAutorized()
{
    var iOSNotificationSettings = iOSNotificationCenter.GetNotificationSettings();
    _iLog.Info(()=> $"SDKManager iOS PushNotificationsSettings with status:{iOSNotificationSettings.AuthorizationStatus} Setting:{iOSNotificationSettings.AlertSetting} and Style:{iOSNotificationSettings.AlertStyle}");
    if (iOSNotificationSettings.AuthorizationStatus == AuthorizationStatus.Authorized)
    {
        StartCoroutine(RequestIOSPushNotificationToken());
    }
}
    
private IEnumerator RequestIOSPushNotificationToken()
{
    _iLog.Info(()=> $"SDKManager requesting iOS PushNotificationsAuthorization");
    using (var req = new AuthorizationRequest(AuthorizationOption.Alert | AuthorizationOption.Badge, true))
    {
        while (!req.IsFinished)
        {
            yield return 0;
        }

        string formattedPushToken = req.DeviceToken.Replace("-", "");
        
        string result = "\n RequestAuthorization: \n";
        result += "\n finished: " + req.IsFinished;
        result += "\n granted :  " + req.Granted;
        result += "\n error:  " + req.Error;
        result += "\n deviceToken:  " + req.DeviceToken;
        result += "\n FormattedDeviceToken:  " + formattedPushToken;
        
        _iLog.Info(() => result);

        if (req.Granted && !string.IsNullOrEmpty(formattedPushToken))
        {
            OnPushTokenReceived(formattedPushToken);
        }
    }
}

I can see the log for "SDKManager requesting iOS PushNotificationsAuthorization" but never the next one (RequestAuthorization), this player has Authorized the notifications already.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.