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. Kafar

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    207

    From OneSignal I send Title and Text fields and a keystring and a value (url) as additional data.
     
  2. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Could you please show me, how you send "title" and "text" fields? Do you use an "additional data" for them the same way as for your url value, or a default OneSignal title and text fields? As you'll need to use additional data to make it work. Also, arguments names should be exactly title and text.

    Best regards,
    Yuriy, Universal Tools team.
     
  3. Kafar

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    207
    I use the OneSignal web console
     
  4. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Of course, but how exactly do you configure the "title" and "text" fields of a message there? Could you please take a screenshot or just make sure that the arguments are passed as a custom user data, the same way as you send url?
     
  5. Kafar

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    207
    Yuriy this is the screenshot from OneSignal web console.
    I write into textbox then I don't know the OneSignal format.


    upload_2016-6-14_20-27-26.png
     
    Last edited: Jun 14, 2016
  6. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Yes, and this is wrong. Your way is suitable for iOS, but not for Android, I already explained why. Please see attached screenshot showing how you can send the message containing title and text in the UTNotifications compatible format:
    Screen Shot 2016-06-14 at 21.09.13.png
     
  7. Kafar

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    207
    Ok, and all Sound, small icon, large icon, big picture, led color, etc?
    And if I want add a link url as additional content?
    Many thanks
     
  8. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    > Sound, small icon, large icon
    See the manual section "Using Notification Profiles (Sounds & Icons Settings)".

    > big picture
    Is not supported in a current version (already added in upcoming version, which is still in development)

    > led color
    Not supported.

    > And if I want add a link url as additional content?
    The same way as any other values - using additional data. The variable name may be any, it's up to you. You may read this value in ReceivedNotification.userData dictionary of any received or clicked notification.

    Regarding clicks handling - I've just checked this functionality - it works fine. Please try reproducing the issue with provided sample scene. If it is reproduced even with it, please tell me affected platforms, your version of Unity and steps to reproduce.

    Best regards,
    Yuriy, Universal Tools team.
     
    Last edited: Jun 14, 2016
  9. nikolafo

    nikolafo

    Joined:
    Dec 27, 2012
    Posts:
    5
    Hey there,
    I just got the package and i got an issue with Notifications. When a shedule notification arrive, it play the sound and get a the small icon in the corner as intended, but i dont get drop down notification. I have to manually drop down the menu notifications bar to see my notification.

    is there a way, or am i doing something wrong, to get the drop down for a few seconds notification? like most applications do?
    (im working on Android 5.1.1)
    Thanks in advance
     
  10. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi nikolafo,

    First of all, thank you for purchasing UTNotifications!

    Could you, please, send me a screenshot of a drop down message shown by other applications, as I'm not sure what are you talking about.

    Thank you and best regards,
    Yuriy, Universal Tools team.
     
  11. nikolafo

    nikolafo

    Joined:
    Dec 27, 2012
    Posts:
    5
    I think the technical name is Heads Up notifications...i get the notification but not the heads up


    (Image: left what i get, Right what i would like)

    BTW the manual and the server works like a charm ;)
     
  12. agurskis

    agurskis

    Joined:
    Jun 10, 2016
    Posts:
    4
    Hello,

    I'm using iOS 8.1.2 device. [It works on Android for some reason]

    I was using UTNotifications for a while and it's just awesome. So simple and easy to use. However, I have never used OnNotificationClicked before. I started using it now, but for some reason it doesn't get called when I click on the notification and when my app launches. It does start though, but no event is fired.

    This is how I set it up:

    Code (CSharp):
    1. Manager.Instance.OnNotificationClicked+=OnNotificationReceived;
    2. Manager.Instance.Initialize(false);
    3.  
    4.     private void OnNotificationReceived(ReceivedNotification notif)
    5.     {
    6.         UnityEngine.Debug.LogError("Clicked on the notification. [id] " + notif.id + " [text] " + notif.text + " [title] " + notif.title);
    7.     }
    I do not get any output when I get back to the app through local notification.

    I schedule the notification using:

    Code (CSharp):
    1. Manager.Instance.ScheduleNotification(fireInSeconds, title, description, notifId);
    Do you know what might be going wrong?

    Thanks,
    Arnold.

    EDIT:

    It works on a new project, but not on the main one I was working on, unfortunately. Something else is conflicting and canceling my notification clicked event.
     
    Last edited: Jun 17, 2016
  13. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi nikolafo,

    OK, I see. The heads-up notifications is Android 5+ only feature, and we support Android 2.3+ (the most important is Android 4.*). But it could make sense to enable heads-up notifications when the app is running on Android 5.0+. I added an appropriate task to our internal task tracking system, so we'll add this functionality in one of upcoming versions.

    Best regards,
    Yuriy, Universal Tools team.
     
    nikolafo likes this.
  14. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Arnold,

    Don't you, probably, cancel all notifications automatically on an application start/activation? Because on iOS it takes 1 frame to handle a clicked notification, and if you cancel all notifications before it was processed, UTNotifications will not know that anything was clicked.

    But if it's not your case, could you please send us to universal.tools.contact@gmail.com a little demo which reproduces the issue, so we'll be able to find what's going on in your specific case?

    Best regards,
    Yuriy, Universal Tools team.
     
  15. Kafar

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    207
    Hi Yuriy,

    About this iOS limitation, there is a workaround or any other way to know IF there are notifications only? GetBadge() return zero in this case. I need to any idea to know when I run the app previously closed if any notification is received or not, then I can open a web browser to send the user on a webpage.

    Thanks for any help.
     
  16. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    You can use silent (raw) remote notifications (see https://developer.apple.com/library...ationsPG/Chapters/TheNotificationPayload.html, section "Configuring a Silent Notification"). But you'll have to implement this functionality on your own as UTNotifications officially don't support silent APNS notifications.

    Best regards,
    Yuriy, Universal Tools team.
     
  17. nikolafo

    nikolafo

    Joined:
    Dec 27, 2012
    Posts:
    5
    Thanks!
     
  18. mayawizard_dev

    mayawizard_dev

    Joined:
    May 25, 2016
    Posts:
    4
    Hi
    I can't build to Android Device The Error is.

    Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
    /Users/suede_boon/Library/Android/sdk/build-tools/23.0.1/aapt package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "/Users/suede_boon/Library/Android/sdk/platforms/android-23/android.jar" -F bin/resources.ap_ --extra-packages universal.tools.notifications:com.facebook:com.facebook.android:com.google.android.gms:com.google.android.gms.ads:com.google.android.gms:android.support.v4 -S "/Users/suede_boon/Data/HeroesGuardian_android/Temp/StagingArea/android-libraries/UTNotifications/res" -S "/Users/suede_boon/Data/HeroesGuardian_android/Temp/StagingArea/android-libraries/facebook-android-sdk-4.7.0/res" -S "/Users/suede_boon/Data/HeroesGuardian_android/Temp/StagingArea/android-libraries/facebook-android-wrapper-release/res" -S "/Users/suede_boon/Data/HeroesGuardian_android/Temp/StagingArea/android-libraries/google-play-services_lib/res" -S "/Users/suede_boon/Data/HeroesGuardian_android/Temp/StagingArea/android-libraries/play-services-ads-8.4.0/res" -S "/Users/suede_boon/Data/HeroesGuardian_android/Temp/StagingArea/android-libraries/play-services-basement-8.4.0/res" -S "/Users/suede_boon/Data/HeroesGuardian_android/Temp/StagingArea/android-libraries/support-v4-23.1.1/res"

    Like some .jar are duplicated.

    Do you have any ideas?
     
  19. Kafar

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    207
    Hello,

    About this topic, for Android I'm doing many trials but with no success. When I receive the push on phone I see the "Wrong Message Format" on Android Notify Area and when I open the app I can see a string concatenation with title, text and other values. I could try to parse the result values to handle the titleand text only but the Wrong Message Format in Notify Area is a problem for the user usability.

    This is a screenshot with the payload I pass to OneSignal to send the push. Do you see any error?
    Many thanks.

    payload.jpg
     
  20. mark7EGames

    mark7EGames

    Joined:
    Jun 23, 2016
    Posts:
    1
    Hello Yuriy,

    I am having problems with grouping android notifications together. I chose the notification profile grouping,
    but when im trying to send a second notif' with a different profile, the new notif' just replaces the old one (even though the "show only latest notification" flag is off!)

    this is the data format i am currently using in my server:
    {
    "GCM": "{ \"data\": { \"title\": \"hjhhh\", \"text\": \"hjhhh\",\"id\": 1,\"notification_profile\": \"chat\"} }"
    }

    The ideal state of stacking notifications for me is setting 2-4 groups that each will show simultaneously if there are present notifs.
    here is a quick sketch of what i need :)
    ______________________________
    | icon...| You got a new message! (3)..|
    |______| user1: wats uppp_________ |
    | icon...| You are under attack!!............|
    |______|________________________|

    as you can see I have 3 notification from group "chat" and one notification from group "under_attack"

    p.s. when I'm using the "Create local notification" button - it specifically pops up as a new notification and doesn't replace my notifications, so i suppose im not using the api right

    I would be very grateful if you can help me solve my problem!
     
    Last edited: Jun 23, 2016
  21. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi mayawizard_dev,

    Sorry for a late answer: Unity forum hasn't informed me about your message (and other new ones). In order to get an assistance ASAP, you can always write us to universal.tools.contact@gmail.com.

    You are right: it's a conflict between UTNotifications and FacebookSDK. Just delete an extra copy of Android Support Library: Assets/Plugins/Android/UTNotifications/libs/android-support-v4.jar. It should help.

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

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Mark,

    I already replied you by email, but just in case will duplicate it here:

    The issue with grouping is quite a popular thing with a misunderstanding how grouped notifications work in Android. Unfortunately, it doesn't create any "summary" notifications containing data about all the notifications in this group, such as your "You got a new message! (3)" example. Instead, you need to create a summary notification on your own, and directly specify that it's a summary for its group. This summary notification can have another style (which is unfortunately not yet supported by UTNotifications). But still it works only this way: you create several notifications of the group, then you create a "group summary" notification which replaces all the shown notifications of the same group, and that's it, Android doesn't do anything else.
    With UTNotifications you specify a "summary" notification by adding a key "notification_group_summary" with any value to the userData dictionary.

    We have plans on automating this process as much as possible in one of future updates, but we've not even started with this feature yet.

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

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    At the first glance your format looks OK. Please give us some time to research the OneSignal API and your issue to find out what's wrong.

    Sorry for this inconvenience.

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

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    207
    Ok, many thanks.
     
  25. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Kafar,

    OK, we figured it out. OneSignal automatically wraps the whole contents of the custom data into the json object "custom" so UTNotifications are unable to find these values.
    So the only way of making it work fine with UTNotifications currently is to read a value "alert" instead of "text" in the Android native plugin.

    I also added a task into our internal task tracking system to try reading the text value from "alert" field if it's not present in the "text". It will be added in one of upcoming updates.

    Best regards,
    Yuriy, Universal Tools team.
     
  26. Kafar

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    207
    Hi,

    This mean I must wait the new plugin update (and when it will be released?) or I can do this to myself? In this case, I must pass a alert key instead the text key as additional content?
     
    Last edited: Jun 24, 2016
  27. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    You don't have to wait of course, as the complete source code is provided.

    No, you'll have to modify the Android native plugin - as I already explained here. You can just change a value of TEXT constant from "text" to "alert". And then, of course, rebuild a plugin.

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

    mdrouillard1983

    Joined:
    May 6, 2016
    Posts:
    1
    I am having a hell of a time getting UTNotifications to work properly, as soon as I call Initialize I get this error:

    Also, I was getting "Unable to convert to DEX" so I had to delete one of the JAR files. android-support-v4.jar, because I think it was conflicting with support-annotations-23.4.0.jar. This is turning out to be a complete MESS can someone please help me figure out wtf is going on. I already have the Google Play Asset installed, so I don't know why it would complain that the Google Cloud Messaging is missing, I even made sure in Android Studio I went into SDK manager and add the google play SDK. HELP!

    07-02 11:43:26.589 8632-8658/? I/Unity: Initializing Notif Manager

    (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
    07-02 11:43:26.679 8632-8658/? I/Unity: AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/gcm/GoogleCloudMessaging;
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/gcm/GoogleCloudMessaging;
    at universal.tools.notifications.GooglePlayProvider.<init>(GooglePlayProvider.java:28)
    at universal.tools.notifications.Manager.initialize(Manager.java:45)
    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    at com.unity3d.player.UnityPlayer.a(Unknown Source)
    at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.gcm.GoogleCloudMessaging" on path: DexPathList[[zip file "/data/app/com.upsilondynamics.rainbowcrush-1/base.apk"],nativeLibraryDirectories=[/data/app/com.upsilondynamics.rainbowcrush-1/lib/arm, /data/app/com.upsilondynamics.rainbowcrush-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
     
  29. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Matt,

    I already answered you by email, but just in case duplicating the same here:

    All the issues you have are caused by conflicts with 3rd party assets, and, of course UTNotifications contains everything it requires to work, but Google Play asset automatically deletes a library used by us. It's a known issue with this asset, here: http://forum.unity3d.com/threads/re...fications-and-more.333045/page-2#post-2454991 you can find the issue description and a way to solve it.

    Feel free to contact me in case of any further difficulties, I'm always happy to help!

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

    PatrickSchulz_xyrality

    Joined:
    Jul 21, 2016
    Posts:
    4
    Hey Yuriy,

    we're getting an error on Android /Samsung devices, that too many push notifications are registered. It Seems that all Samsung devices with lollipop have a cap of 500 notifications.

    The error as follow:
    java.lang.SecurityException: !@Too many alarms (500) registered from pid 8608 uid 10226
    android.os.Parcel.readException(Parcel.java:1620)
    android.os.Parcel.readException(Parcel.java:1573)
    android.app.IAlarmManager$Stub$Proxy.set(IAlarmManager.java:217)
    android.app.AlarmManager.setImpl(AlarmManager.java:484)
    android.app.AlarmManager.set(AlarmManager.java:260)
    universal.tools.notifications.Manager.scheduleNotificationCommon(Manager.java:265)
    universal.tools.notifications.Manager.scheduleNotification(Manager.java:64)

    Do you know this bug? or is there a solution for this issue?
     
  31. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Patrick,

    First of all, thank you for using UTNotifications.

    Unfortunately, the Android alarms count cap is out of control for us. Usually 500 different scheduled notifications is far too much for any application. Could you, probably, consider using ScheduleNotificationRepeating instead of ScheduleNotification?

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

    PatrickSchulz_xyrality

    Joined:
    Jul 21, 2016
    Posts:
    4
    Hi Yuriy,

    we can't use ScheduleNotificationRepeating because we don't send notifications in an interval. They are send after a special time when the user is doing an action in the app. So we have to create a new notification every time. We would like to cancel the notification but it doesn't work.

    More information about this issue:
    Only one device with this android version is currently affected: Android OS 6.0.1 / API-23 (MMB29K/G920FXXU3DPDP)

    Best regards,
    Patrick
     
  33. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Patrick,

    Could you please explain "We would like to cancel the notification but it doesn't work" in more details?
    Does it mean, that you use UTNotifications.Manager.CancelNotification but it doesn't work at all?
    Could you please show the call you use to schedule notifications? How did you try to cancel notifications?
    What notification ids did you use?

    Looking forward to these details to help you with the issue ASAP.

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

    PatrickSchulz_xyrality

    Joined:
    Jul 21, 2016
    Posts:
    4
    Hi Yuriy,

    we use UTNotifications.Manager.Instance.CancelNotification only for android and before we create a new notification we check if there is already a local notification with the same text and cancel that one.

    Code (CSharp):
    1.     private void registerLocalPushNotification(string aNotificationContent, double aSecondsToWaitUntilFire, string anUniqueIdentifier)
    2.     {
    3. #if UNITY_IPHONE && !UNITY_EDITOR
    4.         LocalNotification notification = new LocalNotification();
    5.         notification.alertBody = aNotificationContent;
    6.         if (aSecondsToWaitUntilFire > 0)
    7.         {
    8.             notification.fireDate = DateTime.Now.AddSeconds(aSecondsToWaitUntilFire);
    9.             NotificationServices.ScheduleLocalNotification(notification);
    10.         }
    11.         else
    12.             NotificationServices.PresentLocalNotificationNow(notification);
    13. #elif UNITY_ANDROID && !UNITY_EDITOR
    14.         UTNotifications.Manager.Instance.ScheduleNotification(Convert.ToInt32(aSecondsToWaitUntilFire), notificationTitle, aNotificationContent, anUniqueIdentifier.GetHashCode());
    15. #endif
    16.     }
    17.  
    18.     private bool unregisterLocalPushNotification(string aNotificationContent, string anUniqueIdentifier)
    19.     {
    20. #if UNITY_IPHONE && !UNITY_EDITOR
    21.         foreach (LocalNotification aNotification in NotificationServices.scheduledLocalNotifications)
    22.         {
    23.             if (aNotification.alertBody.Equals(aNotificationContent))
    24.             {
    25.                 NotificationServices.CancelLocalNotification(aNotification);
    26.                 return true;
    27.             }      
    28.         }
    29. #elif UNITY_ANDROID && !UNITY_EDITOR
    30.         UTNotifications.Manager.Instance.CancelNotification(anUniqueIdentifier.GetHashCode());
    31.         return true;
    32. #endif
    33.         return false;
    34.     }
    35.  
    36.     internal void unregisterAllPushNotification()
    37.     {
    38. #if UNITY_IPHONE && !UNITY_EDITOR
    39.         NotificationServices.CancelAllLocalNotifications();
    40. #elif UNITY_ANDROID && !UNITY_EDITOR
    41.         UTNotifications.Manager.Instance.CancelAllNotifications();
    42. #endif
    43.     }
    I hope it helps. If you need more details let me know
     
  35. Treganz

    Treganz

    Joined:
    Feb 2, 2015
    Posts:
    12
    Heyo!

    Having an issue on WSA currently, when I try to build I get the error

    Assets\Plugins\UTNotifications.dll: error CS1704: An assembly with the same simple name 'UTNotifications, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.
    Assets\Plugins\WSA\UTNotifications.winmd: (Location of symbol related to previous error)

    Sure, I have to remove one of those 2 files, and I guess that would have to be Assets\Plugins\UTNotifications.dll, but I'd like a confirmation :)
     
  36. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Patrick,

    First: several advices.
    1. Use UTNotifications for both Android & iOS. Our iOS implementation uses Unity's NotificationsManager internally, but is much smarter - it takes care of several edge cases, supports enabling/disabling notifications in runtime and provides a nice way to handle received and clicked notifications. But what's probably even more important: it will make your code much more clear and straightforward - the whole API of UTNotifications is completely cross-platform.
    2. #elif UNITY_ANDROID && !UNITY_EDITOR. You don't have to use !UNITY_EDITOR with UTNotifications - we take care of this - empty implementation of UTNotifications manager is automatically used when #if UNITY_EDITOR (see Assets/UTNotifications/Src/Dummy/DummyManagerImpl.cs). Actually, if you will use UTNotifications on all platforms, there will be no need in any #ifs on your side.

    Now let's see what's wrong with cancelling scheduled notifications. Could you please try logging all the calls to UTNotifications.Manager.Instance.ScheduleNotification including all the arguments values you're sending and all the calls to UTNotifications.Manager.Instance.CancelNotification (as well, with arguments)? The titles and texts are not important. Then we'll try reproducing the issue to find out what's wrong in this specific case.

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

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Treganz,

    This issue is known and is already fixed (should be available in the upcoming update in about 2 weeks or less). Please don't remove any libraries. Instead, currently you'll have to manually specify the target build platforms:
    In Unity assets browser please find a file Assets/Plugins/UTNotifications.dll. Select it. Then, in the Inspector window you'll see: UTNotifications Import Settings -> Select platforms for plugin. There "Any Platform" option is selected. Please disable it and choose only "Editor" option. It should help. If not, please inform me to get an assistance immediately.

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

    Treganz

    Joined:
    Feb 2, 2015
    Posts:
    12
    Awesome, thanks. I'll check it out tomorrow! :)

    Thanks for the fast response, appreciate it!
     
  39. PatrickSchulz_xyrality

    PatrickSchulz_xyrality

    Joined:
    Jul 21, 2016
    Posts:
    4
    Hey Yuriy,

    thanks for the advices. We'll change it later. :)

    Now here are the calls to cancel Notifications:
    Code (CSharp):
    1.     private void registerRechargeableResourceFullNotification(bool anEnabled)
    2.     {
    3.         registerRechargeableResource("energyMission", anEnabled, true);
    4.         registerRechargeableResource("energyTournament", anEnabled, true);
    5.     }
    6.  
    7.     private void registerRechargeableResource(string aRechargeableResourceName, bool anEnabled, bool anIgnoreNotificationBitmap = false)
    8.     {
    9.         if (anIgnoreNotificationBitmap || isNotificationSet(SNSPushNotificationsBitmapType.ENERGY_FULL))
    10.         {
    11.             if (!string.IsNullOrEmpty(aRechargeableResourceName))
    12.             {
    13.                 string aLocalizedMessage = SNSLocalizer.localize(ENERGY_FULL_PUSH_NOTIFICATION_CONTENT, SNSLocalizer.localize(aRechargeableResourceName));
    14.                 string anUniqueIdentifier = string.Empty;
    15. #if UNITY_ANDROID
    16.                 anUniqueIdentifier = SNSPushNotificationsBitmapType.ENERGY_FULL.ToString() + aRechargeableResourceName;
    17. #endif
    18.  
    19.                 if (anEnabled)
    20.                 {
    21.                     int aCurrentEnergy = playerAvatar.getResourceCount(aRechargeableResourceName);
    22.                     int aMaxEnergy = Convert.ToInt32(SNSResourceSettingsMapper.getResourceSettingValue(aRechargeableResourceName, "regenerateMaxPerDay"));
    23.                     double aSecondsToWaitTillFullEnergy = 0;
    24.                     if (aCurrentEnergy < aMaxEnergy)
    25.                     {
    26.                         int aRegenerateOnePerMinutes = Convert.ToInt32(SNSResourceSettingsMapper.getResourceSettingValue(aRechargeableResourceName, "regenerateOnePerMinutes"));
    27.                         int anAdditionalMissingEnergy = aMaxEnergy - aCurrentEnergy - 1;
    28.                         aSecondsToWaitTillFullEnergy = getSecondsTillNextRequest(playerAvatar.getLastRechargableResourceData(aRechargeableResourceName), aRegenerateOnePerMinutes);
    29.                         if (anAdditionalMissingEnergy > 0) aSecondsToWaitTillFullEnergy += anAdditionalMissingEnergy * (aRegenerateOnePerMinutes * 60);
    30.  
    31.                     }
    32.                     if (isLocalPushNotificationAlreadyRegistered(aLocalizedMessage))
    33.                         unregisterLocalPushNotification(aLocalizedMessage, anUniqueIdentifier);
    34.                     if (aSecondsToWaitTillFullEnergy > 1)
    35.                         registerLocalPushNotification(aLocalizedMessage, aSecondsToWaitTillFullEnergy, anUniqueIdentifier);
    36.                 }
    37.                 else
    38.                 {
    39.                     if (isLocalPushNotificationAlreadyRegistered(aLocalizedMessage))
    40.                         unregisterLocalPushNotification(aLocalizedMessage, anUniqueIdentifier);
    41.                 }
    42.             }
    43.         }
    44.     }
    45.  
    46.     internal bool isLocalPushNotificationAlreadyRegistered(string aNotificationContent)
    47.     {
    48. #if UNITY_IPHONE && !UNITY_EDITOR
    49.         //InfrastructureComponentContainer.Get<SNSPopUpScreenMgr>().openInfoPopup(null, "already exists, local notification: " + NotificationServices.localNotificationCount);
    50.         foreach (LocalNotification aNotification in NotificationServices.scheduledLocalNotifications)
    51.         {
    52.             if (aNotification.alertBody.Equals(aNotificationContent))
    53.                 return true;
    54.         }
    55. #elif UNITY_ANDROID && !UNITY_EDITOR
    56.         return true;
    57. #endif
    58.         return false;
    59.     }
    60.     private double getSecondsTillNextRequest(DateTime aLastEnergyPotionUsage, int aRegenerateOnePerMinutes)
    61.     {
    62.         var aNextRegenerateDate = aLastEnergyPotionUsage.AddMinutes(aRegenerateOnePerMinutes);
    63.         if (aNextRegenerateDate < dataRequester.correctedDateTimeNow)
    64.         {
    65.             aNextRegenerateDate = DateTime.Now.AddMinutes(aRegenerateOnePerMinutes);
    66.         }
    67.         return aNextRegenerateDate.Subtract(dataRequester.correctedDateTimeNow).TotalSeconds;
    68.     }
    69.  
    70.     private bool unregisterLocalPushNotification(string aNotificationContent, string anUniqueIdentifier)
    71.     {
    72. #if UNITY_IPHONE && !UNITY_EDITOR
    73.  
    74.         foreach (LocalNotification aNotification in NotificationServices.scheduledLocalNotifications)
    75.         {
    76.             if (aNotification.alertBody.Equals(aNotificationContent))
    77.             {
    78.                 NotificationServices.CancelLocalNotification(aNotification);
    79.                 return true;
    80.             }      
    81.         }
    82. #elif UNITY_ANDROID && !UNITY_EDITOR
    83.         UTNotifications.Manager.Instance.CancelNotification(anUniqueIdentifier.GetHashCode());
    84.         return true;
    85.  
    86. #endif
    87.         return false;
    88.     }
    89.  
    90.     private void registerLocalPushNotification(string aNotificationContent, double aSecondsToWaitUntilFire, string anUniqueIdentifier)
    91.     {
    92. #if UNITY_IPHONE && !UNITY_EDITOR
    93.         LocalNotification notification = new LocalNotification();
    94.         notification.alertBody = aNotificationContent;
    95.         if (aSecondsToWaitUntilFire > 0)
    96.         {
    97.             notification.fireDate = DateTime.Now.AddSeconds(aSecondsToWaitUntilFire);
    98.             NotificationServices.ScheduleLocalNotification(notification);
    99.         }
    100.         else
    101.             NotificationServices.PresentLocalNotificationNow(notification);
    102. #elif UNITY_ANDROID && !UNITY_EDITOR
    103.         UTNotifications.Manager.Instance.ScheduleNotification(Convert.ToInt32(aSecondsToWaitUntilFire), notificationTitle, aNotificationContent, anUniqueIdentifier.GetHashCode());
    104. #endif
    105.     }
    We are doing it this way multiple times with other notifications. This is only one example.
    I hope it'll help.

    Best regards
    Patrick
     
  40. NicoL3AS

    NicoL3AS

    Joined:
    Oct 7, 2015
    Posts:
    16
    Hello Guys! Just bought UTNotification, seems to be great :)
    Is Firebase Cloud Messaging planned to be handled by the plugin? Google is trying to push more and more devs to use Firebase instead of GCM, I guess GCM will be obsolete in one or two years. What about UTNotification then?
    For more info, here is a link about how to upgrade from GCM to Firebase.
     
  41. QuangSang

    QuangSang

    Joined:
    Jun 4, 2014
    Posts:
    2
    Hi Yuriy,
    I recently just updated the UTNotification SDK to version 1.5.4 (Unity 5.3.5). But I am having issue integrating it. I am using Android SDK 9.2.1 with Play Services Jar Resolver. When I ran the game, it gives me this error when UTNotification is initialized:

    AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/gcm/GoogleCloudMessaging;
    07-26 15:09:18.462 5900 5915 I Unity : java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/gcm/GoogleCloudMessaging;
    07-26 15:09:18.462 5900 5915 I Unity : at universal.tools.notifications.GooglePlayProvider.<init>(GooglePlayProvider.java:28)
    07-26 15:09:18.462 5900 5915 I Unity : at universal.tools.notifications.Manager.initialize(Manager.java:45)
    07-26 15:09:18.462 5900 5915 I Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    07-26 15:09:18.462 5900 5915 I Unity : at com.unity3d.player.UnityPlayer.a(Unknown Source)
    07-26 15:09:18.462 5900 5915 I Unity : at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
    07-26 15:09:18.462 5900 5915 I Unity : Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.gcm.GoogleCloudMessaging" on path: DexPathList[[zip file "/data/app/com.everdead.pennydreadfuldemimonde-1/base.apk"],nativeLibraryDirectories=[/data/app/com.everdead.pennydreadfuldemimonde-1/lib/arm, /data/app/com.everdead.pennydreadfuldemimonde-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
    07-26 15:09:18.462 5900 5915 I Unity : at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56


    I did some research and found that play-services-gcm-9.2.1.aar is missing from the project. So I went ahead and grabbed that library from Android SDK and copied it into the project (Assets/Plugins/Android). But now the game crashed when UT is initialized.

    Any help on this issue?
     
    Last edited: Jul 27, 2016
  42. ph0b0s

    ph0b0s

    Joined:
    Dec 18, 2013
    Posts:
    18
    I´m facing the exactly the same problem, we bought the plugin today and when we include the gcm aar the application crashed after the initialize call. It seems to be some weird problem with that file in the android sdk because everything goes fine if we remove that play-services-gcm.

    Btw we are totally unable to use this asset in this moment, all the work day wasted doing test, removing 3er party sdk´s and in the end it seems to be something related to the android sdk.
     
  43. QuangSang

    QuangSang

    Joined:
    Jun 4, 2014
    Posts:
    2
    @ph0b0s: I fixed that problem by adding play-services-gcm-7.0.0.aar instead of 9.2.1. This is the list of .aar libraries currently in my project atm:
    play-services-auth-base-9.0.2 (for GPGS Signin)
    play-services-base-9.2.1
    play-services-basement-9.2.1
    play-services-drive-9.2.1
    play-services-games-9.2.1
    play-services-gcm-7.0.0
    play-services-nearby-9.2.1
    play-services-tasks-9.2.1
     
  44. ph0b0s

    ph0b0s

    Joined:
    Dec 18, 2013
    Posts:
    18
    I´ll give it a try, but anyway, it seems really weird that with the LATEST library the application crash.
     
  45. ph0b0s

    ph0b0s

    Joined:
    Dec 18, 2013
    Posts:
    18
    Many Thanks QuangSang, It works as workaround by the moment, you save my day.
     
  46. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi Patrick,

    Thanks for the code you sent, but could you, please, send me logs of the calls to ScheduleNotification & CancelNotification with arguments?
    F.e. In the file AndroidManagerImpl.cs, in the method ScheduleNotifications add
    Code (CSharp):
    1. Debug.Log("ScheduleNotification triggerInSeconds = " + triggerInSeconds + "; id = " + id);
    and in the method CancelNotification:
    Code (CSharp):
    1. Debug.Log("CancelNotification id = " + id);
    then please collect logs of this calls in your app (using LogCat) and send us to universal.tools.contact@gmail.com. It will help us researching your issue.

    Thank you a lot for the assistance!

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

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi NicoL3AS,

    We're going to start integrating FCM (for both Android and, optionally, iOS) right after finishing with an upcoming update (UTNotifications 1.6), which is currently being tested and documented. There is no estimation on FCM be available, though. But you can be sure it will be available before Google shuts down the GCM.

    Best regards,
    Yuriy, Universal Tools team.
     
    NicoL3AS likes this.
  48. Yuriy-Ivanov

    Yuriy-Ivanov

    Joined:
    Jun 12, 2015
    Posts:
    466
    Hi QuangSang & ph0b0s,

    Sorry for this inconvenience. The issue with compatibility with latest versions of some 3rd party assets is known and it is already fixed in the upcoming version (1.6), which is now being tested and documented. We hope to make it available in about 2 weeks.

    Best regards,
    Yuriy, Universal Tools team.
     
  49. hattori

    hattori

    Joined:
    Oct 18, 2014
    Posts:
    21
    I've upgraded my Unity version to 5.4 (released yesterday).
    And now I'm getting the following error from UTNotifications in console when I clicked the play button on Unity Editor.
    -------------------------------------------------------
    get_productName is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'Settings'.
    See "Script Serialization" page in the Unity Manual for further details.
    UnityEditor.PlayerSettings:get_productName()
    UTNotifications.Settings:.cctor()
    --------------------------------------------------------

    This is a critical issue for us.
    Plz check it out.

    Cheers.
     
  50. hattori

    hattori

    Joined:
    Oct 18, 2014
    Posts:
    21
    I got this error too.
    ----------------------------
    get_dataPath is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'SettingsEditor'.
    See "Script Serialization" page in the Unity Manual for further details.
    UnityEngine.Application:get_dataPath()
    UTNotifications.Settings:GetAmazonAPIKey() (at Assets/UTNotifications/Src/Settings.cs:276)
    UTNotifications.SettingsEditor:.ctor()
    -----------------------------

    Thanks.