Search Unity

[RELEASED] UTNotifications - Professional Cross Platform Push Notifications and More

Discussion in 'Assets and Asset Store' started by Yuriy-Ivanov, Jun 12, 2015.

  1. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @elfadotonto,
    No, I'm afraid it's not. But you can always store it yourself, if you need it: every time you schedule a notification, add it in a list and serialize the list to a file, which is then loaded on the app start. Feel free to store any details you might need.
    It doesn't require any native platform dependent plugins and is quite easy to implement.

    Best regards,
    Yuriy, Universal Tools team.
     
  2. elfadotonto

    elfadotonto

    Joined:
    Dec 14, 2016
    Posts:
    3
    Another thing. The code below, doesn't consistently post new local notifications. It seems it only work if I click the received one, but then whats the point of using OnNotificationsReceived? Am I using it wrong?

    Code (csharp):
    1.  
    2. public ReschedulingNotificationScheduler()
    3. {
    4.    Manager.Instance.OnNotificationsReceived += HandleReceivedNotifications();
    5.    Manager.Instance.Initialize(true);
    6. }
    7.  
    8. private Manager.OnNotificationsReceivedHandler HandleReceivedNotifications()
    9. {
    10.    return receivedNotifications => { SchenduleQuoteNotification(); };
    11. }
    12.  
    13. public override void SchenduleQuoteNotification()
    14. {
    15.    var index = NextQuote;
    16.    var quote = FindQuote(index);
    17.    Manager.Instance.ScheduleNotification(FindNextOccurrence(), QuoteNotificationTitle, quote, index);
    18. }
    19.  
     
  3. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @elfadotonto,

    Unfortunately no C# code can be invoked while a Unity app is closed (and with default settings, even running in background). So your SchenduleQuoteNotification will only be called when you start an app and construct ReschedulingNotificationScheduler again. The right approach to showing random messages is to schedule them repeated in advance, and then reschedule on each application start.

    F.e. you have a list of N different messages. You can schedule M repeating scheduled notifications, where M is usually >= N * 2 and which are repeated every M periods of time, f.e.:
    1) Random message in range [0, N-1], first show in 1 day (tomorrow), repeat every M days
    2) Random message in range [0, N-1], first show in 2 days (day after tomorrow), repeat every M days
    ...
    M) Random message in range [0, N-1], first show in M days, repeat every M days

    Handling received notifications can be useful if you want to perform some in-game action instead of showing a system notification when your game is running (f.e. highlight an icon indicating you've got your daily bonus ready to be collected).

    Best regards,
    Yuriy, Universal Tools team.
     
  4. elfadotonto

    elfadotonto

    Joined:
    Dec 14, 2016
    Posts:
    3
    Oki, thanks. Met the same problem with katzers cordova.plugin.local-notifications in javascript. Did the same workaround as I did then, with scheduling all daily notifications in bulk when user activates notifications
     
  5. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Hey @Yuriy-Ivanov.
    I've got a question about Push Notifcation handling on Android while in doze state. Do you know if UTNotifications handles the doze state correctly when using GCM, instead of FCM? Or is that only handled with FCM?

    Thanks for the info,
    Patrick
     
  6. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    By default, neither of FCM nor GCM data messages are delivered when the device is in Doze mode. You can mark both GCM and FCM messages as having "high priority" (see https://developers.google.com/cloud-messaging/concept-options and https://firebase.google.com/docs/cloud-messaging/concept-options), so they can be delivered even in Doze mode (although I highly recommend against it, as Doze mode is designed to save energy, as much as possible, and having your app in the list of top energy consumers is not a good idea and might cause customers to even uninstall your app).

    Best regards,
    Yuriy, Universal Tools team.
     
    pahe likes this.
  7. AwesomeSchlimbo

    AwesomeSchlimbo

    Joined:
    Feb 7, 2014
    Posts:
    5
    Hi,
    first of all: nice plugin - thank you. We just migrated from another plugin and this works much better.
    But now we have a problem with encoding. We are using a backend service that provides an API to send messages to every service registration that is found in the database. This can be FCM, GCM, APNS etc.
    So we noticed missing special characters in android and url encoded the strings. Now they look correct on Android but not on IOS. We have no controll over which message is send to FCM or APNS, how can we deal with this problem?
    Thanks and best regards
     
  8. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi Schlimo,

    How urgent is it for you? I could create a modified version of the plugin to avoid URL-encoding, but it might take some time. Besides, what platforms are you interested in: FCM, ADM, WNS (they all currently require URL-encoding)?

    (P.S. URL Encoding will not be required anymore in UTNotifications 1.7 when it's released, hopefully quite soon)

    Best regards,
    Yuriy, Universal Tools team.
     
    Last edited: Nov 25, 2017
  9. AwesomeSchlimbo

    AwesomeSchlimbo

    Joined:
    Feb 7, 2014
    Posts:
    5
    Hi Yuriy,

    we found a backend side solution, but thanks for the offer of the custom plugin.
    Looking forward for version 1.7!
     
  10. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    200
    Hi, I'm having some strange ANR in the google play console for 2 users only :

    ANR:
    executing service com.lagoonsoft.pf/universal.tools.notifications.GcmInstanceIDListenerService

    It happens on:
    HTC Nexus 9 LTE (flounder_lte), 2048MB RAM, Android 7.1
    Hisense C30 (HS8937QC), 2048MB RAM, Android 6.0

    I'm using Unity 2017.1.2 with latest UTNotification 1.6.3

    Does anyone have an idea on how to fix this ?
     
  11. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @Binouze,

    Do you know a way to reproduce the issue? Does it happen all the time on these 2 devices, or happened just one?
    GcmInstanceIDListenerService is a very simple class accessing GCM/FCM API, with almost no own logic, there is basically nothing which could cause ANR (if only Android GCM/FCM API doesn't cause it itself in some weird conditions). We've never observed anything like that, I'm afraid. I'd be glad to take a better look into that issue if you could figure out the reproduction steps.

    Best regards,
    Yuriy, Universal Tools team.
     
  12. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    200
    Sadly I don't know how to reproduce the issue, as I said I saw this on the google play console and I don't have more information about this.
     
  13. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Please let me know us soon as you find out anything.
     
  14. umangdesai

    umangdesai

    Joined:
    Jul 9, 2013
    Posts:
    3
    Hi, I am getting crash when using local notification on Android 8.0

    I am using UTNotification for scheduling local notification.
    Below are the steps to reproduce this crash
    1. Schedule a local notification after 15-20sec
    2. Keep the app open.
    3. Once notification comes click on the notification.
    4. App will crash as soon as you click the notification.

    I tried reproducing the same issue on 6.0 and 7.0 but app is either restarting or opening as it is on these OS.

    Even in logs I am not getting much detail or reason what is causing this crash.
    I am getting this error but no other information.

    A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xdc in tid 15963 (UnityMain)

    Can you please help me with this.
     
  15. isaac_seek

    isaac_seek

    Joined:
    Aug 15, 2017
    Posts:
    1
    I want to use Firebase for both iOS and Android. Firebase sends messages to iOS via APNS if I remember correctly. Is there a quick way to alter your asset so that I can use firebase for iOS like like I am doing for Android?
     
  16. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @isaac_seek ,

    It should indeed be possible, although we've never tried it, so I don't even know how difficult it is. You're pretty much on your own here, I'm afraid.

    Best regards,
    Yuriy, Universal Tools team.
     
  17. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @umangdesai,

    Please, first, try the solution described here: https://forum.unity.com/threads/rel...ications-and-more.333045/page-10#post-3236058
    If it doesn't help, please send us to universal.tools.contact@gmail.com a sample application reproducing the issue and exact steps to reproduce it, we'll figure out what went wrong.

    Best regards,
    Yuriy, Universal Tools team.
     
    Last edited: Nov 30, 2017
  18. richardzzzarnold

    richardzzzarnold

    Joined:
    Aug 2, 2012
    Posts:
    142
    Hi Yuriy,
    I am wondering if it possible by using the DateTime method to start recurring notifications on a particular day of the week. Say I want to have a recurring message starting on a wednesday ( the soonest available wednesday) and repeating every wednesday.How could I do that ?
     
  19. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @richardzzzarnold ,

    Sure, it's pretty simple:
    Code (CSharp):
    1. DateTime now = DateTime.Now;
    2. int daysToAdd = ((int)DayOfWeek.Wednesday + 7 - (int)now.DayOfWeek) % 7;
    3. DateTime nextWednesday = now.AddDays(daysToAdd);
    4. const int WEDNESDAY_NOTIFICATION_ID = 257; // Any unique ID you like
    5. UTNotifications.Manager.Instance.ScheduleNotificationRepeating(nextWednesday, UTNotifications.TimeUtils.DaysToSeconds(7), "Weekly Notification", "Wow! It's Wednesday (again)!", WEDNESDAY_NOTIFICATION_ID);
    I used DateTime.Now as a base DateTime value, so the notification would fire the same time as "now" but on Wednesday. Feel free to specify any time you like in nextWednesday.

    Best regards,
    Yuriy, Universal Tools team.
     
  20. pixelsplit

    pixelsplit

    Joined:
    Sep 16, 2013
    Posts:
    173
    Hi, we now solved the build problem for android (mentioned in the assetstore review). We had to add the following lines to our proguard-user file. Would be pretty cool to have a dedicated proguard file for UTNotifications which is contained in the package.

    # UTNotifications
    -keep public class universal.tools.** { *; }
    -dontwarn android.arch.**
    -dontwarn universal.tools.notifications.**
     
  21. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @zkw,

    The automated patching of proguard-user.txt has been implemented in UTNotifications 1.7 for a while already (btw, android.arch. is not something belonging to UTNotifications). Here are the lines we're automatically adding in 1.7:
    Code (CSharp):
    1. # UTNotifications Proguard Config (please do not edit)
    2. -keep public class universal.tools.notifications.* { *; }
    3. -dontwarn com.amazon.device.messaging.*
    4. -dontwarn universal.tools.notifications.AdmIntentService
    UTNotifications 1.7 is currently being beta-tested and documented and will be published very soon.

    Best regards,
    Yuriy, Universal Tools team.
     
    Last edited: Dec 11, 2017
  22. vstefaniuk

    vstefaniuk

    Joined:
    Oct 1, 2016
    Posts:
    4
    Hi, Yuriy!
    I am getting crashes with next exception:

    Fatal Exception: java.lang.Error: FATAL EXCEPTION [main]
    Unity version : 5.6.3p3
    Device model : AlcatelOneTouch 5049W

    Caused by java.lang.RuntimeException: Unable to start receiver universal.tools.notifications.AlarmBroadcastReceiver: java.lang.SecurityException: Package android does not belong to 10160
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3169)
    at android.app.ActivityThread.-wrap18(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
    at android.os.Handler.dispatchMessage(Handler.java:110)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6309)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

    Caused by java.lang.SecurityException: Package android does not belong to 10160
    at android.os.Parcel.readException(Parcel.java:1683)
    at android.os.Parcel.readException(Parcel.java:1636)
    at android.app.INotificationManager$Stub$Proxy.cancelAllNotifications(INotificationManager.java:794)
    at android.app.NotificationManager.cancelAll(NotificationManager.java:374)
    at universal.tools.notifications.Manager.hideAllNotifications(Manager.java:384)
    at universal.tools.notifications.Manager.postNotificationPrepared(Manager.java:391)
    at universal.tools.notifications.Manager.postNotification(Manager.java:253)
    at universal.tools.notifications.AlarmBroadcastReceiver.onReceive(AlarmBroadcastReceiver.java:14)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3162)
    at android.app.ActivityThread.-wrap18(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
    at android.os.Handler.dispatchMessage(Handler.java:110)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6309)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)



    It may be related to https://forum.unity.com/threads/rel...fications-and-more.333045/page-9#post-3119892

    I am currently in v.1.6.2

    Is it fixed in the newer version, do I have to use the same solution as described in above?
    Thanks!
     
  23. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @vstefaniuk ,

    Can you please provide some more details?
    - Is the issue reproduced for you on any other device model?
    - What versions of Android are affected?
    - Is/are not the affected devices, by chance, rooted?
    - Do you know a specific way to reproduce the issue?

    Looking forward to your answers to help with it,

    Best regards,
    Yuriy, Universal Tools team.
     
  24. vstefaniuk

    vstefaniuk

    Joined:
    Oct 1, 2016
    Posts:
    4
    Hi, @Yuriy-Ivanov

    Issue is *very-low* to repro it affects only ~ 0.001% of all users

    *Operating Systems:*

    Android versions 7 >100%

    7.0 - 53%
    7.1.1 - 47%

    *Devices:*

    88% AlcatelOneTouch
    - 5049W 47%
    - A577VL 46%
    - 5049Z 7%

    6% TCL Wind Tab 10

    6% Yulong REVVLPLUS C3701A



    Thanks!

     

    Attached Files:

    Last edited: Jan 5, 2018
  25. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @vstefaniuk ,

    Thanks for all the details. The issue will not be reproduced in v1.7, which is soon to be published (as we started catching this exception in hideAllNotifications). The root cause of the issue is still unknown to us, but as it that rare, just silently catching the exception should be completely fine.

    Best regards,
    Yuriy, Universal Tools team.
     
    vstefaniuk likes this.
  26. bdominguezvw

    bdominguezvw

    Joined:
    Dec 4, 2013
    Posts:
    96
    Hi @Yuriy-Ivanov,

    I have a problem with your "UTNotificationsDependencies.cs". I see that if you have installed "GooglePlayGames" you check for that version but if not you return "LATEST".

    In our case we use Facebook official sdk that it has a script like this:

    https://github.com/facebook/faceboo...itor/android/AndroidSupportLibraryResolver.cs

    As you can see they force to a specific version so your plugin is conflicting because we need 25.3.1 and having LATEST one we get 27.0.2.
     
    Menion-Leah likes this.
  27. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @bdominguezvw ,

    It's easy to resolve: just replace that "LATEST" with "25.3.1" in UTNotificationsDependencies.cs, then make sure Google Play Services resolver updates the libs.
    Alternatively, you can drop an email us to universal.tools.contact@gmail.com, attaching your UTNotifications purchase receipt you got from Unity Asset Store. Then I'll send you UTNotifications 1.7 (which is now getting documented to be published) - starting with 1.7 you can specify any versions of Play Services Libs and Android Support Library directly in the asset settings in Unity.

    Best regards,
    Yuriy, Universal Tools team.
     
  28. bdominguezvw

    bdominguezvw

    Joined:
    Dec 4, 2013
    Posts:
    96
    Ok, thanks.

    I will wait for 1.7 on Asset Store, I'm not in any hurry.
     
  29. awesomeda

    awesomeda

    Joined:
    May 10, 2017
    Posts:
    11
    Hi Yuriy,

    I have read in the documentation, that notifications with the same ID replace each other. Does this also work local/remote notifications? For example I schedule a local notification with ID 5 and later send a remote notification with ID 5. Somehow in our tests the remote notification didn't replace the local notification (tested only under android).

    Thanks for more information on this.
    David
     
  30. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @awesomeda ,

    The behaviour is different depending on the platform. On iOS showing push notifications is done by the OS itself, so we can't control it, and so push notifications with the same id are not replaced. On Android though they should be replaced the same way as it's done for local notification (the same exact code is responsible for it). Please note, that by default every new push notification gets a new (incremented) id, so they don't replace one another. You can tweak it by an argument of Manager.Initialize or by providing a specific id in the notification payload (the default parameter name is "id"). If it doesn't work for you, please show me an example of a complete FCM message payload (json) you send to FCM servers, I'll check what's wrong.

    Best regards,
    Yuriy, Universal Tools team.
     
  31. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    goodnews.jpg

    Good news, everyone!

    UTNotifications 1.7 has finally been approved by Unity and released in the Asset Store.

    The most important changes:
    - (Breaking change!) Android, Windows Store/UWP: No need to URL-Encode push notifications payload anymore (see DemoServer)
    - (Breaking change!) Minimal officially supported version of Android is now 4.4 (most likely, 4.1+ will work well too)
    - (Breaking change!) Base64 iOS tokens encoding is not supported anymore
    - Android: Android O Notification Channels are fully supported and integrated with notification profiles (please update any existing profiles)
    - Android: Custom notification buttons
    - Android: High Priority/Heads-Up notifications (notification profile settings)
    - Android: Small notification icon background color customization (notification profile settings)
    - Android: UTNotifications.Manager.Instance.NotificationsAllowed() works correctly, like earlier in iOS
    - Android: An option to open a URL instead of the app on a notification tap
    - Android: An option to offer to update the system Google Play if the installed version is too old for FCM
    - Android: Ignoring any misformatted push messages to support AppsFlyer-like services
    - Android: Google Play Services Lib and Android Support Library versions can be specified in the asset settings
    - Android: Automated patching of the Proguard config to make sure UTNotifications classes are not removed when minifying the .apk
    - Android: (Fix) READ_PHONE_STATE permission is not requested anymore when notification profiles are configured
    - iOS: A workaround for a rare iOS bug when local notifications could be duplicated
    - iOS: HTTP/2 API in DemoServer
    - ShortcutBadger and Google Play Services Resolver are updated to the latest versions
    - A number of other fixes and improvements

    Please also take a look at the updated Manual and API Reference.

    Best regards,
    Yuriy, Universal Tools team.
     
    Last edited: Feb 21, 2018
  32. lindsaytalbot

    lindsaytalbot

    Joined:
    Sep 11, 2015
    Posts:
    28
    Hi Yuriy.

    I just updated and I'm getting the following error

    Any idea what this is caused by?
     
    _____nakj likes this.
  33. lindsaytalbot

    lindsaytalbot

    Joined:
    Sep 11, 2015
    Posts:
    28
    Commenting out the line allows the package to compile but notifications aren't working on Android
    Logcat show the following error

     
  34. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @lindsaytalbot ,

    Please uncomment the named line, switch the target platform to something (f.e. a desktop build) and then back to Android, so Unity will import the updated PlayServicesResolver. After that, please make sure all the required dependencies were successfully resolved by it (you might see a dialog showing the resolution process).
    Please let me know if it still doesn't help - in that case please send me your complete list of files and folders in Assets/Plugins/Android, your versions of Unity and Android.

    Best regards,
    Yuriy, Universal Tools team.
     
    lindsaytalbot and _____nakj like this.
  35. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,338
    Hi, is there a way to still support Android 4.1 - 4.3 users with the new version?
    It says it's compatible only down to 4.4.

    Thank you.
     
  36. bledieu

    bledieu

    Joined:
    Nov 10, 2016
    Posts:
    6
    Hello Yuriy

    Any support for Mac App Store apps ?

    Thanks
     
  37. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @_geo__ ,

    Actually, 4.1 and above should work well. We've just chosen 4.4 as the minimal version to be safe - we at the moment don't have any devices running Android version below 4.4, so we couldn't test the app better than in emulator, and as the share of devices with Android 4.1-4.3 is now quite low, we decided to just specify 4.4 as the minimal officially supported version. Most likely everything will be fine with Android 4.1-4.3 too (our Android native plugin is built with minimal API version = 16, i.e. Android 4.1).

    Please let me know if you face any issues, I'll try to help.

    Best regards,
    Yuriy, Universal Tools team.
     
    Last edited: Feb 21, 2018
  38. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @bledieu ,

    Sorry, no, macOS is not supported at the moment.

    Best regards,
    Yuriy, Universal Tools team.
     
  39. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,338
    Hi @Yuriy-Ivanov

    Thanks for the quick reply.
    We still have some users on <= 4.3, so we will give it a try.

    We've still got some other, more pressing issues though.

    On Android 7.1.1 (Test Device: Sony Xperia Z5 Compact) everything works as expected.

    Issue #1) On Android 5.0.1 (Test Device: Samsung Galaxy S4) the Notification does not open the app if the app has been suspended. If you tap the notification it just disappears and nothing happens. Though it opens just fine if the app has been shut down completely.

    An Exception is (sometimes) raised:

    FATAL EXCEPTION: IntentService[NotificationIntentService]
    java.lang.Error: FATAL EXCEPTION [IntentService[NotificationIntentService]]
    Unity version : 5.6.3p4
    Device model : samsung GT-I9515
    Device fingerprint: samsung/jfveltexx/jfvelte:5.0.1...

    Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
    at android.app.ContextImpl.startActivity(ContextImpl.java:1610)
    at android.app.ContextImpl.startActivity(ContextImpl.java:1597)
    at android.content.ContextWrapper.startActivity(ContextWrapper.java:337)
    at universal.tools.notifications.NotificationIntentService.onHandleIntent(NotificationIntentService.java:85)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.os.HandlerThread.run(HandlerThread.java:61)


    Issue #2) On Android 8.0.0 (Test Device: OnePlus 3T) notifications are not shown at all. I have attached an image of the used profile and code. Maybe there is an error? Our guess is that it's due to the new notification channels.

    Unity Version: 5.6.3p4
    UTNotifications Version (1.7, 2018-02-20)
    Android SDK (8.1.0)




    Init Code:
    Code (CSharp):
    1. UTNotifications.Manager.Instance.Initialize( false );
    Trigger Code:
    Code (CSharp):
    1. Dictionary<string, string> userData = new Dictionary<string, string>();
    2. userData.Add("image_url","https://example.com/image.png");
    3.  
    4. var notificationsManager = UTNotifications.Manager.Instance;
    5. notificationsManager.ScheduleNotification( 60, "Title Text", "Message Text", 0, userData, "default" );
    No Exceptions are raised during execution.

    Any obvious errors?
    Thank you for our help.
     
    Last edited: Feb 22, 2018
  40. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @_geo__ ,

    For the first issue: can you please provide specific reproduction steps (starting with an empty Unity project and then the list of actions on a target device), or a sample Unity application (you can send it us to universal.tools.contact@gmail.com)?

    The second: is it really https://example.com/image.png ? As this is actually not an image, and it most likely causes the issue. Have you tried showing a notification without any image or with a normal image URL, like
    http://thecatapi.com/api/images/get?format=src&type=png&size=med, which we use in the sample? Again, if it doesn't help, a sample Unity application would be really appreciated.

    P.S. You don't have to specify "default" as a notification profile name, just skip the last argument. Internally, the default profile name is in fact different, but it's used anyway when the specified profile is missing. One more thing - icon background colors are not supported by Android 7+, it is Android 5-6 only feature.

    Best regards,
    Yuriy, Universal Tools team.
     
    Last edited: Feb 22, 2018
  41. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,338
    Hi @Yuriy-Ivanov,

    thanks again for your swift response.
    Yes, I had swapped the urls for fake ones to make it easier to read. Sorry for the confusion.

    I will send you a PM with a download link to the demo project shortly.

    You can download the demo app directly if you like:
    https://games.modalog.at/sniper/utn.apk

    Behaviour is still the same in the demo as in the real game.

    Reproduce (Issue 1, Error) - On Android 5.0.1
    1. Build and install the apk
    2. Tap one button (doesn't matter which)
    3. Suspend the app (press the home button)
    4. Wait for the notification
    5. Tap the notification
    6. ERROR: The notification closes but the app does not open.
    Reproduce (Issue 1, Success)- On Android 5.0.1
    1. Build and install the apk
    2. Tap one button (doesn't matter which)
    3. Force close the app (press the home button, swipe it of the screen)
    4. Wait for the notification
    5. Tap the notification
    6. The notification closes and the app starts.
    Reproduce (Issue 2) - On Android 8.1.0
    1. Build and install the apk
    2. Tap one button (doesn't matter which)
    3. Suspend or force close the app (doesn't matter what you do)
    4. Wait for the notification
    5. ERROR: It never shows up.

    Thanks :)
     
    Last edited: Feb 23, 2018
  42. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @_geo__ ,

    Please find the solution for both issues in PM.

    Best regards,
    Yuriy, Universal Tools team.
     
  43. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,338
    Hi,
    thanks for the quick fix.

    Issue #1) It now works just fine on Android 5.0, great!
    Issue #2) It's now also working on Android 8.1.

    Here are the solutions:
    #1) was an error in the plugin. To my knowledge a patch release will follow shortly.
    #2) We specified the string "default" for the notificationProfile parameter in the ScheduleNotification() Method. Don't do that, use NULL instead.

    Great job (working on weekends, your're insane ;-)
     
    Last edited: Feb 27, 2018
  44. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    291
    Hi, just bought this and testing it out, two issues:

    1. Seeing a lot of exceptions logged, these looped endlessly after installing the asset, restarting unity cleared that up but still seeing them when editing a notification profile:


    2. Custom icons don't seem to work - I've added a profile that's pointing at custom icons, am specifying it in the scheduleNotification calls and still getting the little bell icon on Android.
     
  45. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    291
    Also seeing this in logcat on scheduling a notification:

     
  46. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi @Aurigan ,

    The first issue is a known bug in XML API implementation in some versions of Unity. As a workaround, please add attribute
    Code (CSharp):
    1. xmlns:amazon="http://schemas.amazon.com/apk/res/android"
    in node manifest of Assets/Plugins/Android/AndroidManifest.xml, f.e.
    Code (CSharp):
    1. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0" xmlns:amazon="http://schemas.amazon.com/apk/res/android">
    2. Haven't you, by chance, moved any of UTNotifications files or folders to any other folder? It's the most common cause of this problem. I strongly recommend you against moving UTNotifications to any other location (or at least update all the appropriate constants in Settings.cs). If it's not your case, please send a sample Unity project us to universal.tools.contact@gmail.com and I'll check what's wrong with it.

    Best regards,
    Yuriy, Universal Tools team.
     
  47. Tr3gan

    Tr3gan

    Joined:
    Dec 13, 2016
    Posts:
    11
    Hey @Yuriy-Ivanov ,

    So we just updated to 1.7 and maybe you can still remember that our app relies on device time instead of time since boot (RTC_WAKEUP instead of ELAPSED_REALTIME). I'm going through the native plugin, but I see quite a lot has changed in manager.java. What do I need to change to make it fit our app again?

    Oh, and could you maybe also send me a fix for issue #1 that @_geo__ was having here https://forum.unity.com/threads/rel...ications-and-more.333045/page-11#post-3400208 ?

    When I run the app, I'm getting exceptions related to the native Android plugin:
    Code (CSharp):
    1. AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='fcmProviderAvailable' signature='()Z' in class Ljava.lang.Object;
    2.  
    3. java.lang.NoSuchMethodError: no static method with name='fcmProviderAvailable' signature='()Z' in class Ljava.lang.Object;
    4. com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source)
    5. com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    6. com.unity3d.player.UnityPlayer.c(Unknown Source)
    7. com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source)
    8. android.os.Handler.dispatchMessage(Handler.java:98)
    9. android.os.Looper.loop(Looper.java:145)
    10. com.unity3d.player.UnityPlayer$c.run(Unknown Source)
    11. UnityEngine.AndroidJNISafe.CheckException ()
    12. UnityEngine.AndroidJNISafe.CallStaticObjectMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] args)
    13. UnityEngine.AndroidReflection.GetMethodMember (IntPtr jclass, System.String methodName, System.String signature, Boolean isStatic)
    14. UnityEngine._AndroidJNIHelper.GetMethodID (IntPtr jclass, System.String methodName, System.String signature, Boolean isStatic)
    15. UnityEngine.Debug:LogException(Exception)
    16. Debug:LogException(Exception)
    17. UTNotifications.ManagerImpl:PushNotificationsEnabled()
    However, looking through the native source, that method definitely exists. I've already made sure that the plugin .aar is up-to-date, but the error remains.

    -EDIT-
    Ah, check out line 150 in AndroidManagerImpl, it calls fcmProviderAvailable without bool parameter, while the native plugin does expect that :)

    Thanks for the hard work on 1.7, looks like lots of great improvements!

    Yours,
    Bas
     
    Last edited: Mar 1, 2018
  48. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    291
    Hey Yuriy, thanks for the reply - the manifest hack did clear up that issue. For the notification icon I did have UTNotifications in the Assets folder ... I then tried just setting the default profile icons and ... that worked! So it seems that creating a custom profile and setting the icons on that, then calling e.g.

    Manager.Instance.ScheduleNotification(fireAfterSec, title, contents, (int)id, notificationProfile:"swarm");

    won't work to select the icon set up on the 'swarm' profile.
     
  49. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Hi Bas,

    I've sent you both the fixes in PM. A hotfix will be published soon.

    Best regards,
    Yuriy, Universal Tools team.
     
  50. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Just checked it (just in case), notification profiles work as expected in 1.7. Can you please send a Unity project reproducing that issue to universal.tools.contact@gmail.com, so I'll check what went wrong in your case?

    Thank you.

    Best regards,
    Yuriy, Universal Tools team.