Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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

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

  1. Tr3gan

    Tr3gan

    Joined:
    Dec 13, 2016
    Posts:
    11
    Perfect, thanks!
     
  2. Janoschii

    Janoschii

    Joined:
    Oct 15, 2014
    Posts:
    9
    Hi @Yuriy-Ivanov

    Can we use UTNotifications with Cloud Build? I ask, cause we work on Windows and didn't use XCode in our app development workflow. And I couldn't find any informations about deploying the app with UTNotifications and Cloud Build in your manual. If this is possible, it would be nice if you could add this in the manual.
     
  3. Yuriy-Ivanov

    Yuriy-Ivanov

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

    Yes, Cloud Builds are supported, but in the latest version there is a minor mistake, preventing Android Cloud Builds: we forgot to disable an editor-only call in case of cloud builds:
    #if UNITY_EDITOR && UNITY_ANDROID && !UNITY_CLOUD_BUILD
    You can add this check marked bold in SettingsEditor.cs (line 329).

    The rest should work alright, including iOS cloud builds.

    Best regards,
    Yuriy, Universal Tools team.
     
    Janoschii likes this.
  4. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    87
    Hello @Yuriy-Ivanov, you'r asset looks promising - does it support push notification based on GPS position? (geofencing)
     
  5. Yuriy-Ivanov

    Yuriy-Ivanov

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

    No, unfortunately geo-fencing notifications are not supported.

    Best regards,
    Yuriy, Universal Tools team.
     
  6. lindsaytalbot

    lindsaytalbot

    Joined:
    Sep 11, 2015
    Posts:
    28
    For those who had a bit of trouble, it's actually lines 328, and the UNITY_EDITOR flag is missing as well
    Here's line 328 to 329
    Code (CSharp):
    1.  
    2. #if UNITY_EDITOR && UNITY_ANDROID && !UNITY_CLOUD_BUILD
    3. UTNotificationsDependencies.ResolveDependencies();
    4. #else
    5.  
    Also, I'm still having issues with the "Google Play Services does not exist" issue. Switching worked platforms back and forth worked once, but after switching branches and back again it's come up and hasn't gone away even after switching platforms again. Switching platforms takes about 15 minutes each way so it's not something I've had plenty of time to test with.
     
  7. lindsaytalbot

    lindsaytalbot

    Joined:
    Sep 11, 2015
    Posts:
    28
    Interesting fun fact, the (car) emoji leaks data on Android 19. Testing on our Samsung Galaxy Tab 3 Lite and each character for the car emoji is replaced with random text and series of characters that looks like java code.
     
  8. Yuriy-Ivanov

    Yuriy-Ivanov

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

    Unfortunately it's a Unity problem: it's often unable to refresh Google's Play Services Resolver Editor dlls itself. Hopefully Unity people will fix it. Using Play Services Resolver is the lesser of two evils, without it there are much more critical inter-plugin conflict related issues.

    Is it the case with local or push notifications? In the first case, can you please show how you schedule a local notification (including its text of course), if push: can you please post here or send me to email a complete push notification payload causing that issue? If there is something misformatted, I can help you fixing it, if there is a bug in our native plugin, we'll fix it ourselves and I'll send you a patch asap.

    Best regards,
    Yuriy, Universal Tools team.
     
  9. lindsaytalbot

    lindsaytalbot

    Joined:
    Sep 11, 2015
    Posts:
    28
    They're local notifications.

    Not sure if the emoji will show up in the code, but I've tested these two and they both do it.
    https://emojipedia.org/oncoming-automobile/
    https://emojipedia.org/trophy/

    The screenshot is just 22 "OncomingCar" emoji's in a row. I tried including the emoji compat library and it didn't help - it still leaks.

    Code (CSharp):
    1.  for (int i = 0; i < 10; i++)
    2.         {
    3.             UTNotifications.Manager.Instance.ScheduleNotification(DateTime.Now + new TimeSpan(0, 0, 5 * i), "Title ", "", i); //body is OncomingAutomabile 22 times. Forum doesn't show it
    4. }
    5.  
    We've been getting a lot of crash reports on Android (about 3.7%) with the following error and was wondering if it was related. The error has been happening on all versions of Android, 4.4 all the way up to 8+

     
  10. awesomeda

    awesomeda

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

    we integrated the firebase SDK into our app and since then we get a lot of those reports in the google play store. I don't know if it has anything to do with integrating the firebase sdk or not because we are not able to reproduce it. What could cause this exception and how can we fix it?

    Edit: we are using plugin version 1.6.3

    Thanks
    David

    java.lang.Error: FATAL EXCEPTION [main]
    Unity version : 5.6.5p1
    Device model : samsung SM-G928F
    Device fingerprint: samsung/zenltexx/zenlte:7.0/NRD90M/G928FXXS3CQL5:user/release-keys
    Caused by
    at android.app.ActivityThread.handleReceiver (ActivityThread.java:3316)
    at android.app.ActivityThread.-wrap20 (ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1715)
    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 (Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
    Caused by: java.lang.RuntimeException:
    at android.graphics.Bitmap.nativeWriteToParcel (Native Method)
    at android.graphics.Bitmap.writeToParcel (Bitmap.java:2000)
    at android.graphics.drawable.Icon.writeToParcel (Icon.java:744)
    at android.app.Notification.writeToParcelImpl (Notification.java:1966)
    at android.app.Notification.writeToParcel (Notification.java:1899)
    at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag (INotificationManager.java:892)
    at android.app.NotificationManager.notifyAsUser (NotificationManager.java:336)
    at android.app.NotificationManager.notify (NotificationManager.java:292)
    at android.app.NotificationManager.notify (NotificationManager.java:276)
    at universal.tools.notifications.Manager.postNotificationPrepared (Manager.java:423)
    at universal.tools.notifications.Manager.postNotification (Manager.java:254)
    at universal.tools.notifications.AlarmBroadcastReceiver.onReceive (AlarmBroadcastReceiver.java:14)
    at android.app.ActivityThread.handleReceiver (ActivityThread.java:3309)
     
  11. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    OK, that's really interesting. The thing is: there is no not only java.net.URLDecoder.decode, but even universal.tools.notifications.Manager.prepareNotification in UTNotifications 1.7, although it was there in 1.6.x. Are you sure you imported the 1.7.1 completely, including all the Android native plugins?

    Regarding the emoji issue: thanks for letting me know, we'll look into it.

    UPDATE: I can confirm the emoji issue on Android 4.x. We're looking for a workaround for it. Will let you know as soon as there is a solution.
     
    Last edited: Mar 14, 2018
    lindsaytalbot likes this.
  12. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Theoretically it might be caused by a newer version of Android support library imported by Firebase SDK (although, without clear steps to reproduce that issue, it's difficult to validate this idea).

    I'd recommend you updating UTNotifications, if possible: the newer version is designed to work correctly with the latest versions of Android SDK, including the latest Android system libs. The code causing the exception in your case was heavily reworked in 1.7.
     
  13. lindsaytalbot

    lindsaytalbot

    Joined:
    Sep 11, 2015
    Posts:
    28
    Awesome. The live version was using 1.6.x and we haven't managed to push 1.7 live. Hopefully that fixes it. (Emoji issue was tested with 1.7)
     
  14. Yuriy-Ivanov

    Yuriy-Ivanov

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

    The Emoji issue is caused by Android 4/5 own JNI issue: https://stackoverflow.com/questions...4-0-ndk-newstringutf-is-crashing-down-the-app. It causes corruption of any stings passed to any Android native plugins, if these strings contain Unicode characters with the code values >10000 (mostly quite recent emojis).

    I've sent you in a private message a patch, which Base64-encodes and then decodes in the java code notifications titles, texts, userdata and buttons configurations, to avoid these unicode chars passing through JNI, which is used by Unity to make any calls from C# code to Android native plugins. Please note though, that Android 4.x doesn't have the oncoming car unicode character support, so though it doesn't cause issues passing the arguments, these emojis will be missing. Android 5 and newer have them.

    Best regards,
    Yuriy, Universal Tools team.
     
    lindsaytalbot likes this.
  15. MapMan

    MapMan

    Joined:
    Oct 27, 2013
    Posts:
    38
    Hello @Yuriy-Ivanov ! I purchased UTN recently and I have trouble making it work. Neither local or push notifications work.

    I imported the plugin to its default locations. Configured the settings (e.g. to always show a notification, not just when an app is closed) and resolved the dependencies.

    On game start up I initialize the Manager singleton instance.

    When try to do a simple, local notification nothing happens. Here's my adb log (just the relevant bits):
    Code (CSharp):
    1. Shortly after game start up (maybe these messages are harmless?):
    2. I/dalvikvm(16207): Could not find method android.app.Notification$Builder.<init>, referenced from method universal.tools.notifications.Manager.buildNotification
    3. W/dalvikvm(16207): VFY: unable to resolve direct method 205: Landroid/app/Notification$Builder;.<init> (Landroid/content/Context;Ljava/lang/String;)V
    4. D/dalvikvm(16207): VFY: replacing opcode 0x70 at 0x0084
    5. E/dalvikvm(16207): Could not find class 'android.app.Notification$Action$Builder', referenced from method universal.tools.notifications.Manager.buildNotification
    6. W/dalvikvm(16207): VFY: unable to resolve new-instance 34 (Landroid/app/Notification$Action$Builder;) in Luniversal/tools/notifications/Manager;
    7. D/dalvikvm(16207): VFY: replacing opcode 0x22 at 0x00f8
    8. I/dalvikvm(16207): Could not find method android.app.Notification$Builder.setGroupSummary, referenced from method universal.tools.notifications.Manager.buildNotification
    9. W/dalvikvm(16207): VFY: unable to resolve virtual method 228: Landroid/app/Notification$Builder;.setGroupSummary (Z)Landroid/app/Notification$Builder;
    10. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x0202
    11. I/dalvikvm(16207): Could not find method android.app.Notification$Builder.setGroup, referenced from method universal.tools.notifications.Manager.buildNotification
    12. W/dalvikvm(16207): VFY: unable to resolve virtual method 227: Landroid/app/Notification$Builder;.setGroup (Ljava/lang/String;)Landroid/app/Notification$Builder;
    13. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x0234
    14. I/dalvikvm(16207): Could not find method android.app.Notification$Builder.setGroup, referenced from method universal.tools.notifications.Manager.buildNotification
    15. W/dalvikvm(16207): VFY: unable to resolve virtual method 227: Landroid/app/Notification$Builder;.setGroup (Ljava/lang/String;)Landroid/app/Notification$Builder;
    16. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x025f
    17. I/dalvikvm(16207): Could not find method android.app.Notification$Builder.setGroup, referenced from method universal.tools.notifications.Manager.buildNotification
    18. W/dalvikvm(16207): VFY: unable to resolve virtual method 227: Landroid/app/Notification$Builder;.setGroup (Ljava/lang/String;)Landroid/app/Notification$Builder;
    19. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x0268
    20. I/dalvikvm(16207): Could not find method android.app.Notification$Builder.setColor, referenced from method universal.tools.notifications.Manager.setSmallIcon
    21. W/dalvikvm(16207): VFY: unable to resolve virtual method 214: Landroid/app/Notification$Builder;.setColor (I)Landroid/app/Notification$Builder;
    22. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x0020
    23. D/dalvikvm(16207): DexOpt: unable to opt direct call 0x00ba at 0x106 in Luniversal/tools/notifications/Manager;.buildNotification
    24. E/dalvikvm(16207): Could not find class 'android.app.NotificationChannel', referenced from method universal.tools.notifications.Profile.registerChannel
    25. W/dalvikvm(16207): VFY: unable to resolve new-instance 44 (Landroid/app/NotificationChannel;) in Luniversal/tools/notifications/Profile;
    26. D/dalvikvm(16207): VFY: replacing opcode 0x22 at 0x0007
    27. D/dalvikvm(16207): DexOpt: unable to opt direct call 0x010a at 0x11 in Luniversal/tools/notifications/Profile;.registerChannel
    28. D/dalvikvm(16207): DexOpt: unable to opt direct call 0x0355 at 0x47 in Luniversal/tools/notifications/Profile;.registerChannel
    29. I/dalvikvm(16207): Could not find method android.app.NotificationManager.getNotificationChannel, referenced from method com.google.android.gms.common.GoogleApiAvailability.zza
    30. W/dalvikvm(16207): VFY: unable to resolve virtual method 277: Landroid/app/NotificationManager;.getNotificationChannel (Ljava/lang/String;)Landroid/app/NotificationChannel;
    31. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x000f
    32. I/dalvikvm(16207): Could not find method android.app.Notification$Builder.setChannelId, referenced from method com.google.android.gms.common.GoogleApiAvailability.zza
    33. W/dalvikvm(16207): VFY: unable to resolve virtual method 213: Landroid/app/Notification$Builder;.setChannelId (Ljava/lang/String;)Landroid/app/Notification$Builder;
    34. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x007c
    35. I/dalvikvm(16207): Could not find method android.support.v4.app.NotificationCompat$Builder.setChannelId, referenced from method com.google.android.gms.common.GoogleApiAvailability.zza
    36. W/dalvikvm(16207): VFY: unable to resolve virtual method 2936: Landroid/support/v4/app/NotificationCompat$Builder;.setChannelId (Ljava/lang/String;)Landroid/support/v4/app/NotificationCompat$Builder;
    37. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x00de
    38. I/dalvikvm(16207): Could not find method android.app.NotificationManager.getNotificationChannel, referenced from method com.google.android.gms.common.GoogleApiAvailability.setDefaultNotificationChannelId
    39. W/dalvikvm(16207): VFY: unable to resolve virtual method 277: Landroid/app/NotificationManager;.getNotificationChannel (Ljava/lang/String;)Landroid/app/NotificationChannel;
    40. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x000e
    41. D/dalvikvm(16207): DexOpt: unable to opt direct call 0x010a at 0x1c in Lcom/google/android/gms/common/GoogleApiAvailability;.zza
    42. I/dalvikvm(16207): Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.zzp.zzv
    43. W/dalvikvm(16207): VFY: unable to resolve virtual method 507: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
    44. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x0012
    45. I/dalvikvm(16207): Could not find method android.content.pm.PackageManager.isInstantApp, referenced from method com.google.android.gms.internal.zzbhe.zzamu
    46. W/dalvikvm(16207): VFY: unable to resolve virtual method 513: Landroid/content/pm/PackageManager;.isInstantApp (Ljava/lang/String;)Z
    47. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x002d
    48. I/dalvikvm(16207): Could not find method android.content.Context.getNoBackupFilesDir, referenced from method com.google.android.gms.common.util.zzv.getNoBackupFilesDir
    49. W/dalvikvm(16207): VFY: unable to resolve virtual method 372: Landroid/content/Context;.getNoBackupFilesDir ()Ljava/io/File;
    50. D/dalvikvm(16207): VFY: replacing opcode 0x6e at 0x0006
    51.  
    52. When trying to send a notification:
    53. W/ResourceType(16207): No package identifier when getting value for resource number 0x00000000
    54. E/universal.tools.notifications.Manager(16207): java.lang.NullPointerException
    When I send a push notification from AWS SNS to the user the adb log tells a little bit more, maybe it will shed some more light on what's happening:
    Code (CSharp):
    1. W/Bundle  (16748): Key google.sent_time expected String but value was a java.lang.Long.  The default value <null> was returned.
    2. W/Bundle  (16748): Attempt to cast generated internal exception:
    3. W/Bundle  (16748): java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
    4. W/Bundle  (16748):     at android.os.Bundle.getString(Bundle.java:1121)
    5. W/Bundle  (16748):     at universal.tools.notifications.Manager.bundleToMap(Manager.java:515)
    6. W/Bundle  (16748):     at universal.tools.notifications.Manager.postPushNotification(Manager.java:361)
    7. W/Bundle  (16748):     at universal.tools.notifications.GcmIntentService.onMessageReceived(GcmIntentService.java:10)
    8. W/Bundle  (16748):     at com.google.android.gms.gcm.GcmListenerService.handleIntent(Unknown Source)
    9. W/Bundle  (16748):     at com.google.android.gms.iid.zzc.run(Unknown Source)
    10. W/Bundle  (16748):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    11. W/Bundle  (16748):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    12. W/Bundle  (16748):     at java.lang.Thread.run(Thread.java:841)
    13. W/Bundle  (16748): Key google.ttl expected String but value was a java.lang.Integer.  The default value <null> was returned.
    14. W/Bundle  (16748): Attempt to cast generated internal exception:
    15. W/Bundle  (16748): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
    16. W/Bundle  (16748):     at android.os.Bundle.getString(Bundle.java:1121)
    17. W/Bundle  (16748):     at universal.tools.notifications.Manager.bundleToMap(Manager.java:515)
    18. W/Bundle  (16748):     at universal.tools.notifications.Manager.postPushNotification(Manager.java:361)
    19. W/Bundle  (16748):     at universal.tools.notifications.GcmIntentService.onMessageReceived(GcmIntentService.java:10)
    20. W/Bundle  (16748):     at com.google.android.gms.gcm.GcmListenerService.handleIntent(Unknown Source)
    21. W/Bundle  (16748):     at com.google.android.gms.iid.zzc.run(Unknown Source)
    22. W/Bundle  (16748):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    23. W/Bundle  (16748):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    24. W/Bundle  (16748):     at java.lang.Thread.run(Thread.java:841)
    25. W/ResourceType(16748): No package identifier when getting value for resource number 0x00000000
    26. E/universal.tools.notifications.Manager(16748): java.lang.NullPointerException
    It is worth mentioning that SOME parts of the plugin are working, for instance, I am able to retrieve device registration id via OnSendRegistrationId event on Manager.

    EDIT:
    An interesting insight. If I disable push notifications, the local notifications do work (both in demo scene and in my set up). When push notifications are enabled, neither push or local notifications work. Moreover, the various dalvikvm logs are also present when push notifications are disabled and local notifications work. This strengthens the hypothesis that they are harmless.

    Any ideas what's wrong?
     
    Last edited: Mar 21, 2018
  16. MapMan

    MapMan

    Joined:
    Oct 27, 2013
    Posts:
    38
    After restarting unity multiple times and forcibly resolving dependencies, push notifications (and local) started to work. Not sure exactly what was wrong. Any ideas, for future reference?
     
  17. Yuriy-Ivanov

    Yuriy-Ivanov

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

    It seems that Android Support Library was missing (or outdated) in your project. It might happen when Google Play Services Resolver libraries are not updated or refreshed by Unity (which is a known Unity problem). We usually advise switching platform to something except Android (f.e. Desktop) and back to Android to make Unity reimport the editor-only dlls.
    As soon as all the required libraries are imported, you shouldn't face any issues again. But if you do, feel free to contact us (the fastest way is usually email), we'll be glad to help.

    P.S. You can ignore the "Key google.sent_time expected String but value was a java.lang.Long" messages, these exceptions are caused by interpreting any push payload values except of title, text and so on as user data strings. These exceptions are logged but handled properly by our Android native plugin - these non-string values will be skipped when building the user data map.

    Best regards,
    Yuriy, Universal Tools team.
     
    MapMan likes this.
  18. ViggyMo

    ViggyMo

    Joined:
    Jan 20, 2014
    Posts:
    4
    Hi, as you've already mentioned this plugin adds a lot of field references due to the Google Play libs. I'm trying to use this plugin just for local notifications and I don't need server-side push notifications. If that's the case, can you tell me which of the following libs I can safely remove in an effort to keep my total field references below the limit of 65536? And if I delete the unnecessary ones, will the plugin still initialize okay or will it crash somewhere? Thanks!

    1738 com.google.android.gms
    20 com.google.android.gms.actions
    16 com.google.android.gms.ads.identifier
    43 com.google.android.gms.auth.api.signin
    10 com.google.android.gms.auth.api.signin.internal
    1738 com.google.android.gms.base
    1738 com.google.android.gms.base.license
    104 com.google.android.gms.common
    98 com.google.android.gms.common.api
    340 com.google.android.gms.common.api.internal
    41 com.google.android.gms.common.data
    44 com.google.android.gms.common.images
    160 com.google.android.gms.common.internal
    1738 com.google.android.gms.common.license
    35 com.google.android.gms.common.stats
    27 com.google.android.gms.common.util
    25 com.google.android.gms.dynamic
    20 com.google.android.gms.dynamite
    2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags
    16 com.google.android.gms.flags.impl
    1844 com.google.android.gms.gcm
    1738 com.google.android.gms.gcm.license
    1798 com.google.android.gms.iid
    1738 com.google.android.gms.iid.license
    800 com.google.android.gms.internal
    5 com.google.android.gms.location.places
    6 com.google.android.gms.security
    1788 com.google.android.gms.tasks
    1738 com.google.android.gms.tasks.license
     
  19. Yuriy-Ivanov

    Yuriy-Ivanov

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

    It's simple: in
    Assets/UTNotifications/Editor/Android/UTNotificationsDependencies.cs
    , comment out/remove the following lines (40-43):
    Code (CSharp):
    1.             Google.VersionHandler.InvokeInstanceMethod(svcSupport, "DependOn", new object[] { "com.google.android.gms", "play-services-gcm", Settings.Instance.GooglePlayServicesLibVersion }, namedArgs: new Dictionary<string, object>()
    2.             {
    3.                 { "packageIds", new string[] { "extra-google-m2repository" } }
    4.             });
    Then save the file and activate the Unity Editor window (switch to Android platform, if it's not yet activated). You should see a dialog displaying the library resolution process, when it's finished all the extra libraries will be gone (only the required Android Support Library with its dependencies will be left).
    if not, enforce the resolution process by a menu action
    Assets -> Play Services Resolver -> Android Resolver -> Resolve
    .

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

    ViggyMo

    Joined:
    Jan 20, 2014
    Posts:
    4
    Thanks Yuriy, this worked perfectly. Great plugin, great support!
     
  21. DanielKaiserman

    DanielKaiserman

    Joined:
    Mar 29, 2018
    Posts:
    1
    Hello there!

    I'm running into an issue with local notifications right now. Whenever I test clicking on a notification, it's opening up the last app I had in use, not my app. I'm on 1.7.1, and I believe I've eliminated the possiblity of it being device related.

    Any and all help appreciated, been very happy using UTNotifications as its fulfilling all of my needs simply and easily.

    Cheers.
     
  22. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    That's very weird indeed. Can you probably send us to universal.tools.contact@gmail.com a sample Unity project reproducing that issue, and instructions on reproducing it? Please also tell me what versions of Android you tested it with.

    Looking forward to hearing from you to help sort it out asap.

    Best regards,
    Yuriy, Universal Tools team.
     
  23. abe_unity264

    abe_unity264

    Joined:
    Nov 10, 2017
    Posts:
    3
    Using this asset, I was able to create a local push of the alarm clock.
    Thank you very much.

    On a bright day, there was a request from the client side.
    That is to add a push notification using Firebase.
    I'm hastening to implement Android only.

    It did not work just by installing the json file.
    So I downloaded FirebaseMessaging.unitypackage from official website.
    It worked normally by installing this.

    But there are two problems.

    1. When sending from Firebase, two notifications are displayed.
    2. Icons and sounds are not displayed in notification sent from Firebase.

    Please tell me about these two solutions.

    Also, is it correct that you introduced FirebaseMessaging.unitypackage?

    I am not good at English, it became a bad word, but I hope you can answer.
     
  24. Yuriy-Ivanov

    Yuriy-Ivanov

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

    First of all, thank you for using our asset.
    UTNotifications doesn't support push notifications sent with Firebase Console, as it's limited to send only "notification" FCM messages, which can't be properly handled by an app. This is why we require "data" messages to support all the UTNotifications functionality. You can find more details in section "Push Notifications Payload Format" of our manual.

    You might indeed choose to use Unity Firebase SDK to handle FCM in your applications, instead of appropriate functionality of UTNotifications. In that case please disable FCM toggle in the UTNotifications settings to avoid any issues with duplicated messages. Please note, that icons/sounds functionality of UTNotifications works only if you use our asset to handle push notifications, Unity Firebase SDK can't work with our system of notification profiles. Please refer to their documentation in order to configure look and behavior of FCM notifications handled by their SDK.

    Best regards,
    Yuriy, Universal Tools team.
     
  25. abe_unity264

    abe_unity264

    Joined:
    Nov 10, 2017
    Posts:
    3
    thank you very much!
    Thanks to you I got clues. :D
     
  26. acastenmiller

    acastenmiller

    Joined:
    Sep 15, 2016
    Posts:
    4
    We purchased this plugin a while ago and everything appeared to be working fine. I was testing on a Samsung Galaxy S7 with Android 7.0 installed. The notifications would show the main App Icon in the notifications without problem. However it was recently noticed on other Android devices we were showing a white/grey square.

    So I went in and updated to custom icons, which have just white and transparency. I believe this solves the issue for those devices. However, on the devices that didn't have the problem in the past, I believe it still insists on showing the icon at full colour. So since I now made the icon white with transparency, on the devices that didn't have the problem before, it shows the icon as white, even if it's on a white background. So you can't really see the icon (see screenshot).

    To workaround this I've made the icon grey - it looks fine now on the main notification banner, but in the top status bar it is also grey, which looks a bit dull (also see screenshot). It would be preferable if the Android OS did the colouring for it (making the top status bar icon white and the one on the main screen grey), which seems to work in another push notification service we're using (currently mainly using UTNotifications for local notifications).

    I tried experimenting with changing the different Small Icons in the settings. I found that on my device, it is using the "Small Icon (Android 5.0+)", so I believe this still needs to have transparency to work. I noticed the "?" help for it took me to a stack overflow thread, which just confused me even further.

    I've attached a picture explaining the problem, hopefully that makes more sense than what I wrote!
     

    Attached Files:

  27. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    In Android 5.0 and newer, any color information of small icons is ignored: Android takes any non-transparent pixels and replaces their color to some contrast color to be well seen against the current background (the color might change depending on the background). It's weird it used white color on the white background in your case. Can you please tell me the affected version of Android and probably send an example icon to reproduce the issue (you can send it in a private message)? Have you tried specifying a background color (Android 5-7) to make sure the icon is contrast (f.e. you might use any dark color in this case) - it's configured in the notification profile settings.

    Btw, what's the target Android API you specify in AndroidManifest.xml or build settings (if any is specified)?

    Best regards,
    Yuriy, Universal Tools team.
     
    Last edited: Apr 19, 2018
  28. Theinsanekiller

    Theinsanekiller

    Joined:
    Jun 1, 2012
    Posts:
    27
    Hi Yuriy,
    We are currently using version 1.6.3, and we are not getting notifications for Oreo os. Is there anything that we are missing. Do we need to update the plugin?
     
  29. Yuriy-Ivanov

    Yuriy-Ivanov

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

    Yes, Android 8+ requires any notification to specify a notification channel, which has to be defined in advance by the application. UTNotification 1.7 addresses it among other changes (notification profiles define a notification channel each). Please update to the latest version of the asset available in the asset store.

    Best regards,
    Yuriy, Universal Tools team.
     
  30. HonkaHonka

    HonkaHonka

    Joined:
    Feb 14, 2013
    Posts:
    4
    Hello Yuriy,
    I already wrote an e-mail but maybe here the response is faster.
    We updated to the latest version, by simply going in unity to the asset store tab. There to the plugin. Clicked download and importing the plugin. In the next screen we simply hit import.
    After that we ran into several issues.
    First: Merge Android Manifest is not working, because of min and target SDK. So we adjusted those to the required values.
    After that, we ran into the error: unable to convert classes into dex format
    Maybe the solution is this here: https://answers.unity.com/questions/1248566/unable-to-convert-classes-into-dex-format-9.html
    But I have no idea how to find out, which classes are duplicate. Is this a known problem?
    How can I find out if this is the problem, and what can I do to solve it?

    By the way, is that the right way to update your plugin?

    *EDIT*
    We found the error by comparing the imported version, versus the existing data in the project. The file which created the error is: ShortcutBadger-1.1.5.aar
    The new file is: ShortcutBadger-1.1.21.aar
    Deleting: ShortcutBadger-1.1.5.aar did the trick for us.
    *EDIT*

    Thanks for any help, regards,
    Martin
     
    Last edited: Apr 27, 2018
  31. Yuriy-Ivanov

    Yuriy-Ivanov

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

    I'm glad you figured it out and sorry I couldn't help faster (I've replied you be email before I read this forum post).
    Feel free to contact us by email or forum in case of any further issues.

    Best regards,
    Yuriy, Universal Tools team.
     
  32. HonkaHonka

    HonkaHonka

    Joined:
    Feb 14, 2013
    Posts:
    4
    Hello Yuriy,
    we updated from 1.6 to the newest version, 1.7.1.
    We ran into another problem. The app icon is not displayed any longer. Instead I see on Android a small bell - I guess the default.
    In UTNotification Settings I specified the app logos for android under: "Notification profiles".
    I added the app icon in small and big.
    But now I am stuck. Any help is appreciated.

    Regards,
    Martin
     
  33. Yuriy-Ivanov

    Yuriy-Ivanov

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

    I suppose you're using default profile? There is a known issue in 1.7.1 which might cause this behavior with default profiles on Android. The issue is already fixed and will be released with the next update very soon. Could please try configuring a custom notification profile with any arbitrary name of your choice (f.e. "profile"), and then specify that profile name when posting a notification?

    In case it doesn't help, could you please send us to universal.tools.contact@gmail.com a sample project with your configuration of notification profiles to reproduce the issue, so I might check what's going on?

    Best regards,
    Yuriy, Universal Tools team.
     
  34. HonkaHonka

    HonkaHonka

    Joined:
    Feb 14, 2013
    Posts:
    4
    Hi Yuriy, I was using a custom made one. That did not work. So I used the default one. That did not work, so I looked at the specifics and saw, that I had to resize my icons to 96 or 192.
    That did the trick for me. On my Galaxy S6 Edge + I do get the notification, with 2 app icons. 1 very small on the top left and one medium one on the right side.
    I do get the error "missing debug.keystore" - which I do not know. But since I am able to build a build, it is fine for me.

    One question is now open the moment: How can I display multiple incoming message with an increasing number on the app icon? Right now there is only a "1" instead of a "3" for example. Any idea?

    Thanks for your reply on this short notice.

    Best regards,
    Martin
     
  35. Yuriy-Ivanov

    Yuriy-Ivanov

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

    Unfortunately due to iOS badges API you can't increment badge numbers, only set specific values, which is a huge disappointment for me too. Technically incrementing can be done in Android, but we don't provide that functionality at the moment to provide as cross-platform as possible API. You have 4 primary options here:
    1. Use push notifications and calculate the badge number for each customer on your server. F.e. increment per-customer counter every time you send them a new notification, and as soon as they start your app, it informs your server so you reset the counter.
    2. Use "1" always, just to display there is something new with your app.
    3. (Works only with non-repeating scheduled notifications). You might predict the badge number when scheduling a notification: as you can save all scheduled notifications with their date/time, you can calculate the badge number to show for a new scheduled notifications. Of course, every time customer starts your app, you would have to recalculate the badges and update all notifications scheduled for future with their new badge numbers.
    4. (Android only) implement badges incrementing in UTNotifications Android native plugin, which source code is provided with the asset.

    Sorry, but that's all you got at the moment.

    Best regards,
    Yuriy, Universal Tools team.
     
  36. MapMan

    MapMan

    Joined:
    Oct 27, 2013
    Posts:
    38
    Hello @Yuriy-Ivanov ,

    I have a feature request (or maybe it's already a feature but I'm missing it?). I would like to be able to tell whether a notification with a specific id is scheduled or not.

    To give some context: I'm creating a couple of local notifications where user explicitly has to ask to be notified about something, e.g. user clicks a button to be notified when his energy is fully refilled. If a notification is already scheduled, the button should be disabled and there should be a text saying that the user will be notified when his energy will be full. Without the ability to tell whether a specific notification is actually scheduled, this is hard, albeit not impossible, to achieve. For instance, everytime I schedule the notification I also have to save a player prefs flag indicating that the notification was scheduled. Each time the game is started, I have to check the value of that flag and see whether user is at max energy already (meaning the notification was delivered when app was closed), if not, then the notification is still scheduled. Handling all the possible cases (e.g. restarting app, app sitting idly, app being in the background, user logging out etc.) adds a lot of unnecessary complexity.

    Having a method that returns true if a notification is scheduled would make all of this really easy. The method should return false if there is no such notification scheduled (including the case where it was scheduled and was delivered already).

    Hopefully this would be a low effort for you, but high impact for the plugin users.

    Regards
     
  37. Yuriy-Ivanov

    Yuriy-Ivanov

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

    It makes total sense. Feel free to add an appropriate ticket: https://github.com/universal-tools/UTNotificationsFeedback/issues.
    Though, please note, that it's not easily done, due to limitations of underlying OSes, so we'll have to implement the logic you described ourselves.

    Best regards,
    Yuriy, Universal Tools team.
     
  38. MrSaoish

    MrSaoish

    Joined:
    Oct 1, 2016
    Posts:
    22
    Hi,

    Firstly thank you for making UTnotification, and I have just purchased it from Unity Asset Store. I am not an android developer, but I am currently developing an app using Unity which require sending message from a server. There are 3 questions I would like to ask:

    1. Could I use UTnotification to make the client subscribe to certain topic while using FCM? If not, are you planning adding such feature anytime soon?

    2. I appreciate your efforts on showing us how to set up a server, but I don't know java. So it's very hard for me to extend functionalities with your demoServer. Instead, I built a very simple server just to send FCM notification to certain topic, on the client side, it's getting the OnNotificationsReceived callback when the app is on foreground; however, it doesn't get the OnNotificationClicked callback if I click on the FCM notification. I wonder if it's because the channel/notification profile was not right, and I have tried specify notification_profile and android_channel_id, but it seems like the received notification is been categorize to "Miscellaneous". I used following classes to construct a FCM notificaiton:
    Code (CSharp):
    1.     [System.Serializable]
    2.     public class FCMMessage {
    3.         public string to; // topic or registration id
    4.         public Dictionary<string,string> data;
    5.         public FCMNotification notification;
    6.         public FCMMessage(string dest, string title, string body) {
    7.             this.to = dest;
    8.             this.notification = new FCMNotification(title, body);
    9.             this.data = new Dictionary<string, string>() {
    10.                 {"title", title },
    11.                 {"text", body },
    12.                 {"notification_profile","default" }
    13.             };
    14.         }
    15.         public void AddData(string key, string value) {
    16.             if (data == null) data = new Dictionary<string, string>();
    17.             data.Add(key, value);
    18.         }
    19.     }
    20.  
    21.     [System.Serializable]
    22.     public class FCMNotification {
    23.         public string title;
    24.         public string body;
    25.         public string android_channel_id = "default";
    26.         public FCMNotification(string title, string body) {
    27.             this.title = title;
    28.             this.body = body;
    29.         }
    30.     }
    And I use FCM Legacy HTTP protocol to send a notification to a topic like this:
    Code (CSharp):
    1. string json = Serializer.ToNewtonJson(fcmMessage);
    2.                 byte[] bytes = Serializer.GetUTF8Bytes(json);
    3.                 WebRequest request = WebRequest.Create(url);
    4.                 request.Method = "post";
    5.                 request.ContentType = "application/json";
    6.                 request.Headers.Add($"Authorization: key={legacyServerKey}");
    7.                 request.Headers.Add($"Sender: id={senderID}");
    8.                 request.ContentLength = bytes.Length;
    9.                 using (Stream dataStream = request.GetRequestStream()) {
    10.                     dataStream.Write(bytes, 0, bytes.Length);
    11.                     using (WebResponse response = request.GetResponse()) {
    12.                         using (Stream dataStreamResponse = response.GetResponseStream()) {
    13.                             using (StreamReader reader = new StreamReader(dataStreamResponse)) {
    14.                                 string responseFromServer = reader.ReadToEnd();
    15.                                 result = responseFromServer;
    16.                             }
    17.                         }
    18.                     }
    19.                 }
    3. For the "High Priority (Heds-Up)" in profile, I notice checking this option doesn't make notification pop up on my Android 8.1.0 device. I'm not if this issue remains for other version, but for my device, the notification importance level need to be set to "Urgent" in order to see a pop up.
    Screenshot_20180507-004800.png
     
  39. Yuriy-Ivanov

    Yuriy-Ivanov

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

    1. Topic are not supported at the moment, as our native code is based on an upgraded ex-GCM API internally (although it's using FCM keys and servers). We are going to update it at some point, but without any known release date: it can take a while, as we're very busy with our primary projects. We'd like to add topics support then.
    2 & 3. "notification" & "notification" + "data" FCM messages are handled by Android OS itself, many of UTNotifications features don't work in that case. Please send "data"-only messages. Fore more details please see https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages.

    Best regards,
    Yuriy, Universal Tools team.
     
  40. MrSaoish

    MrSaoish

    Joined:
    Oct 1, 2016
    Posts:
    22
    Base on your input. I have changed my FCMMessage to this:
    Code (CSharp):
    1.     [System.Serializable]
    2.     public class FCMMessage {
    3.         public string to; // topic or registration id
    4.         public Dictionary<string,string> data;
    5.         //public FCMNotification notification;
    6.         public FCMMessage(string dest, string title, string body) {
    7.             this.to = dest;
    8.             //this.notification = new FCMNotification(title, body);
    9.             this.data = new Dictionary<string, string>() {
    10.                 {"title", title },
    11.                 {"text", body },
    12.                 {"notification_profile","default" }
    13.             };
    14.         }
    15.         public void AddData(string key, string value) {
    16.             if (data == null) data = new Dictionary<string, string>();
    17.             data.Add(key, value);
    18.         }
    19.     }
    The OnNotificationsReceived callback can be raised normally. However, there is no notification at all when the app is running at background or been killed. Am I missing something?

    [UPDATE]

    I got it working with OneSignal, but it leads to a problem:

    On android, a window would be prompted upon notification received if the app is at foreground which is unexpected. Could you please tell me where to disable such option? Untitled.png
     
    Last edited: May 8, 2018
  41. Yuriy-Ivanov

    Yuriy-Ivanov

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

    This dialog - that's not us! Something else in your project handles the received notification and shows that dialog. It's either a 3rd party library or something you do in OnNotificationsReceived. Most likely the first option. Please check it.

    Regarding it not working with your server: it either caused by the same 3rd party library that shows that dialog or what's happening with that FCMMessage instance later - how it's serialized to json and sent to FCM servers. If you could send me a complete message as sent to FCM, I could check what's wrong with it, if anything.

    Best regards,
    Yuriy, Universal Tools team.
     
    MrSaoish likes this.
  42. MrSaoish

    MrSaoish

    Joined:
    Oct 1, 2016
    Posts:
    22
    You are absolutely right, I found that the dialog was popped because of OneSignal SDK. See detail here.
     
  43. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    Please note, that you don't really need OneSignal SDK if you use UTNotifications: our native plugins work well with messages received from OneSignal. You can also use their API to register devices with registration ids produced by UTNotifications in their servers.

    You might still prefer to use their SDK for handling push notifications, in that case please don't forget to disable appropriate push notifications platforms toggles in UTNotifications settings to avoid various conflicts with their plugins.
     
    MrSaoish likes this.
  44. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    233
    Hi,
    There is a way to ask iOS users for the notifications permission later in the game, not at the first launch?
    Also, there is a way to check if the notifications permission is enabled or not for both iOS and Android?
     
  45. Yuriy-Ivanov

    Yuriy-Ivanov

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

    Both yes.

    1. This dialog is shown first time you call UTNotifications.Manager.Instance.Initialize. So don't call it (and so don't use any notifications functionality, as it requires that permission) unless you're ready to disturb the user with the permission dialog.
    2. See UTNotifications.Manager.Instance.NotificationsAllowed.

    Best regards,
    Yuriy, Universal Tools team.
     
    Wadjey likes this.
  46. shark812

    shark812

    Joined:
    Dec 6, 2012
    Posts:
    13
    I've the exact same issue right now, any fix?
     
  47. Yuriy-Ivanov

    Yuriy-Ivanov

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

    This issue is known to affect some Android devices with UTNotifications 1.7.1 and older. Please drop an email to universal.tools.contact@gmail.com attaching your purchase receipt and I'll send you an update: it will be a pre-release version of UTNotifications 1.7.2 (except of the new sample, which is now being finalized) - this issue is fixed there.

    Alternatively, you might wait until 1.7.2 is published in the asset store and then download it right from there.

    Best regards,
    Yuriy, Universal Tools team.
     
    shark812 likes this.
  48. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    233
    Hi,
    Does UTNotifications supports IL2CPP for iOS/Android/UWP platforms?
     
  49. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    495
    iOS/Android - yes, UWP - no (as UWP notifications require a background service, which can only be defined in a .winmd plugin, and Unity doesn't support .winmd libraries with IL2CPP).
     
  50. shark812

    shark812

    Joined:
    Dec 6, 2012
    Posts:
    13
    I've sent you an e-mail with the receipt, is this version also fixed for the Android Cloud Build?
     
unityunity