Search Unity

Free Android local notifications plugin open source

Discussion in 'Android' started by Nihilitik, Mar 11, 2015.

  1. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    HadesKratos, ata_2, larku and 2 others like this.
  2. Enki

    Enki

    Joined:
    Jun 2, 2013
    Posts:
    20
    Cool, adding it now, thanks! I was looking for a simple solution, without all the junk I don't need.
     
  3. Enki

    Enki

    Joined:
    Jun 2, 2013
    Posts:
    20
    Quick Q: What would the delay be for say once per week? I'm only guessing it's in seconds...
     
  4. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    You have to put delay in seconds, in LocalNotification.cs it converts to milliseconds and come to plugin.
    1 week = 60 * 60 * 24 * 7 = 604800
     
    Enki likes this.
  5. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Cool plugin! Is it easy to add a firedate in the Android Java code? So let's say I want daily repeating notifications on:
    8:00
    13:00
    19:00
     
  6. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    You can get delta seconds between now and firedate:

    DateTime dt = new DateTime(2015, 4, 1, 14, 30, 0, 0);
    long deltaSeconds = (dt - DateTime.Now).TotalSeconds;
     
  7. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Thanks for the reply, I've tried to add this but I can't test if it works because I get an error that the Java class can't be found. I'm guessing there is an error in my AndroidManifest.xml
    Can you take a look at it?
    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest
    3.         xmlns:android="http://schemas.android.com/apk/res/android"
    4.         package="com.devfo.andutils"
    5.         android:versionName="1.2"
    6.         android:versionCode="2">
    7.    
    8.     <uses-permission android:name="android.permission.INTERNET" />
    9.     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    10.     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    11.     <uses-permission android:name="android.permission.READ_CONTACTS" />
    12.  
    13.     <supports-screens
    14.         android:smallScreens="true"
    15.         android:normalScreens="true"
    16.         android:largeScreens="true"
    17.         android:xlargeScreens="true"
    18.         android:anyDensity="true" />
    19.    
    20.     <application
    21.         android:icon="@drawable/app_icon"
    22.         android:label="@string/app_name"
    23.         android:debuggable="true">
    24.    
    25.         <!-- NOTIFY java -->
    26.         <receiver android:name="net.agasper.unitynotification.UnityNotificationManager"></receiver>
    27.         <!-- end -->
    28.  
    29.         <activity
    30.             android:name="com.devfo.andutils.DevfoUnityPlayerActivity"
    31.             android:label="@string/app_name"
    32.             android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    33.             android:screenOrientation="portrait">
    34.                 <intent-filter>
    35.                     <action android:name="android.intent.action.MAIN" />
    36.                     <category android:name="android.intent.category.LAUNCHER" />
    37.                     <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
    38.                 </intent-filter>
    39.                 <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    40.                 <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    41.         </activity>
    42.  
    43.         <activity android:name="com.unity3d.player.VideoPlayer" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
    44.         </activity>
    45.     </application>
    46.  
    47. </manifest>
    And my code for adding the notification:


    Code (CSharp):
    1.  
    2. private static string fullClassName = "net.agasper.unitynotification.UnityNotificationManager";
    3. private static string unityClass = "com.unity3d.player.UnityPlayerNativeActivity";
    4.  
    5. DateTime temp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute + 1, DateTime.Now.Second);
    6.  
    7. CreateTempNotification("Test", "Message", temp, 4);
    8.  
    9. private void CreateTempNotification(string title, string message, System.DateTime fireDate, int KeyValue)
    10.     {
    11.         Debug.Log("CREATING TEMP NOTIFICATION AT DATE: " + fireDate.ToString());
    12.  
    13.         #if UNITY_ANDROID && !UNITY_EDITOR
    14.         AndroidJavaClass pluginClass = new AndroidJavaClass(fullClassName);
    15.         if(pluginClass != null)
    16.         {
    17.             bool sound = true;
    18.             bool vibrate = true;
    19.             bool lights = true;
    20.  
    21.             long notif01 = (long)(fireDate - DateTime.Now).TotalSeconds;
    22.  
    23.             Debug.Log ("Date1: " + notif01);
    24.  
    25.             pluginClass.CallStatic("SetRepeatingNotification", KeyValue, unityClass, notif01, title, message, message, 60*60*24 * 1000, sound ? 1 : 0, vibrate ? 1 : 0, lights ? 1 : 0);
    26.         }
    27.         #endif
    28.  
    29.         Debug.Log ("SEND TEMP NOTIFICATION");
    30.     }
     
    Last edited: Mar 25, 2015
  8. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    Try to change unityClass to "com.devfo.andutils.DevfoUnityPlayerActivity", seems that you have plugins conflict
     
  9. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Thanks again for the reply! I'm still getting this error when running my game and creating the notification:
    I've changed the unityClass to "com.devfo.andutils.DevfoUnityPlayerActivity"
     
  10. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    Try to rollback and remove other plugins
     
  11. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    So I removed all the plugins and reimported the files from your demo project. It's working now! Only problem i'm having, is when sending a notification (not repeating) I see the notification and icon in the notification bar on my Android Phone (vibration and light is also working). But when scheduling a repeating notification I get the vibration and the light but no icon, title and message is showing in the bar. Is this a bug?
     
  12. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    Plugin updated. Bugs fixed and added better compatibility with Android Lollipop
     
    Tripwire likes this.
  13. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Great it's working perfect now! One thing I would advise you to do in your code. In the SendRepeatingNotification (Unity3D script) you use long timeout, wouldn't it be better to change that to repetition?
     
  14. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Hi Nihilitik

    I've implemented the Android notifications, and it's working fine. But there is a small problem that I hope you know how to get fixed. When I set the notifications, there are always 2 firing immediately. Thereafter it works like it's suppose to work. Here's my code:

    Code (CSharp):
    1. public void CreateNotification()
    2. {
    3. DateTime date01 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 08, 00, 00);
    4.             DateTime date02 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 13, 00, 00);
    5.             DateTime date03 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 19, 00, 00);
    6.  
    7. SendRepeatingNotification(1, date01, Language.Get("Notification_Header01"), Language.Get("Notification_Message01"), new Color32(18, 115, 196, 255));
    8.             SendRepeatingNotification(2, date02, Language.Get("Notification_Header01"), Language.Get("Notification_Message01"), new Color32(18, 115, 196, 255));
    9.             SendRepeatingNotification(3, date03, Language.Get("Notification_Header01"), Language.Get("Notification_Message01"), new Color32(18, 115, 196, 255));
    10. }
    11. public static void SendRepeatingNotification(int id, DateTime fireDate, string title, string message, Color32 bgColor, bool sound = true, bool vibrate = true, bool lights = true, string bigIcon = "")
    12.     {
    13.         long delay =(long) (fireDate - DateTime.Now).TotalSeconds;
    14.         long rep = 60 * 60 * 24;
    15.         #if UNITY_ANDROID && !UNITY_EDITOR
    16.         AndroidJavaClass pluginClass = new AndroidJavaClass(fullClassName);
    17.         if (pluginClass != null)
    18.         {
    19.             pluginClass.CallStatic("SetRepeatingNotification", id, unityClass, delay * 1000L, title, message, message, rep * 1000, sound ? 1 : 0, vibrate ? 1 : 0, lights ? 1 : 0, bigIcon, "notify_icon_small", bgColor.r * 65536 + bgColor.g * 256 + bgColor.b);
    20.         }
    21.         #endif
    22.     }
     
  15. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    fireDate should be always greater than DateTime.Now. You are creating dateXX wrong
     
    Tripwire likes this.
  16. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    I feel silly thx man! Fixed it and now it's working perfectly :)
     
  17. kuravista

    kuravista

    Joined:
    Jun 21, 2012
    Posts:
    4
    Hi Nihilitik
    your code is awesome, it's working when i build alone in android.

    but when i build with Vuforia plugin and i change the AndroidManifest.xml
    the script notification not work
    can you help me ??

    Code (JavaScript):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.qualcomm.QCARUnityPlayer" android:versionCode="1" android:versionName="1.0">
    3.  
    4.   <!-- NOTIFY java -->
    5.   <receiver android:name="net.agasper.unitynotification.UnityNotificationManager"></receiver>
    6.   <!-- end -->
    7.    
    8.   <uses-sdk android:minSdkVersion="8" />
    9.   <uses-feature android:name="android.hardware.camera" />
    10.   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" />
    11.   <uses-permission android:name="android.permission.INTERNET" />
    12.   <uses-permission android:name="android.permission.CAMERA" />
    13.   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    14.     <uses-permission android:name="android.permission.VIBRATE" />
    15.   <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:debuggable="false">
    16.     <activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity" android:label="@string/app_name" android:screenOrientation="sensor" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    17.       <meta-data android:name="android.app.lib_name" android:value="unity" />
    18.       <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    19.       <intent-filter>
    20.         <action android:name="android.intent.action.MAIN" />
    21.         <category android:name="android.intent.category.LAUNCHER" />
    22.       </intent-filter>
    23.     </activity>
    24.     <activity android:name="com.unity3d.player.VideoPlayer" android:label="@string/app_name" android:screenOrientation="sensor" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    25.     </activity>
    26.     <activity android:name="com.devfo.andutils.DevfoUnityPlayerActivity" android:label="@string/app_name" android:screenOrientation="sensorLandscape">
    27.     </activity>
    28.   </application>
    29.  
    30. </manifest>
    31. <!-- android:installLocation="preferExternal" -->
     
  18. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    If you changed default Unity activity to Vuforia in manifest, you have to change it in LocalNotification.cs:9
    to com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity
     
  19. acoto87

    acoto87

    Joined:
    May 10, 2015
    Posts:
    2
    I'm testing your plugin and it work fine with your unity test project, but when I try to integrate it to my game doesn't work. I think it maybe an issue with other plugins I have in the game like Google Play Games Services, AdColony, Everyplay and Google Analytics. Each plugins of these brings their own manifest that are merged by unity at compilation.

    My question is: do you know any common issues that can appear when these plugins are put all together?

    Also I noted that your test project is targeting to Android 4.1, this is the minor version that I need to target when use this plugin?

    I also need to open the game when the user touch the notification, it would great for everyone if you can add it.

    Thanks in advance, good job with this plugin.
     
  20. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    Please post your manifest here
     
  21. acoto87

    acoto87

    Joined:
    May 10, 2015
    Posts:
    2
    Hi, thanks for the response, but I was able to make it work by merging the manifest by myself and delete the others. It seems that problem was that, in this case, for some reason Unity doesn't merge well the various manifest files of the plugins. Specifically doesn't put the receiver tag.

    Nevertheless, I had to test with several configurations in the manifest, and the one that works was with this two meta-data under the main activity tag with these specific values:

    <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />

    Can you tell me why this is? Why the unityplayer.ForwardNativeEventsToDalvik must be set to false?

    Thanks again.
     
  22. Deathtruth

    Deathtruth

    Joined:
    Feb 12, 2014
    Posts:
    3
    Hi Nihilitik, when using LocalNotification.CancelNotification(0); I get the error "Unfortunately myGame has stopped". When the notification was due to arrive. The id for the cancel and the notification are matching (0). Is this a bug in the plugin or am I doing something wrong? Thanks!

    Thanks for the plugin.

    I am using android 5.0 and unity 5.0 btw.
     
  23. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    it do not worked for me on android KitKat
     
  24. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    Try to use ID > 0, if it doesn't help send me stack trace from ADB
     
  25. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    What does it mean ? Please send me stack trace from ADB
     
  26. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    I did not got what you said and what is ADB
    but i used the demo scene and even send a custom notification myself after 5-10 secs and no mater app is open or closed it did not showed any notification (no remote)
     
  27. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    I will test it with KitKat, but now i don't have appropriate device
     
  28. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    No matter atleast you are trying to help I'll wait
     
  29. Deathtruth

    Deathtruth

    Joined:
    Feb 12, 2014
    Posts:
    3
    Hey Nihilitik, thanks for the help. I tried using an ID greater than 0 but still crashes. I'll upload my crash log. I had a look through it first and found this which might be of help.

     

    Attached Files:

    • log2.rar
      File size:
      84.6 KB
      Views:
      531
  30. teemukorh

    teemukorh

    Joined:
    Oct 28, 2014
    Posts:
    49
    Thanks for the plugin. Noticed that I get the same crash, e.g. when scheduling a notification in OnApplicationFocus() when going background. Any ideas?
     
  31. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    Guys, plz attach your manifests. I can't retry this exception.
     
  32. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    any idea on kitkat?
    :D
     
  33. Nihilitik

    Nihilitik

    Joined:
    Nov 25, 2011
    Posts:
    19
    Sorry man, i still don't have KitKat
     
  34. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    no problem.
    I wait or probably test in other devices . ;)
     
  35. teemukorh

    teemukorh

    Joined:
    Oct 28, 2014
    Posts:
    49
    I have the manifest same manifest from the git repo. I'll try to create a test project tomorrow and share it.
     
  36. Deathtruth

    Deathtruth

    Joined:
    Feb 12, 2014
    Posts:
    3
    Just to confirm I have the same manifest as the one from your git repository.

    Using Lollipop on Note 4.
     
  37. LittleNiu

    LittleNiu

    Joined:
    Oct 18, 2014
    Posts:
    5
    HI,Guys,I have the same problem with you.And I change some code,now work OK.
    In java class UnityNotificationManager, function onReceive,I remove the code below
    Code (CSharp):
    1. Class<?> unityClassActivity = null;
    2. try {
    3.   unityClassActivity = Class.forName(unityClass);
    4.     } catch (ClassNotFoundException e) {
    5.     e.printStackTrace();
    6.      }
    And change
    Code (CSharp):
    1. Intent notificationIntent = new Intent(context,
    2.                 unityClassActivity.class);
    To
    Code (CSharp):
    1. Intent notificationIntent = new Intent(context,
    2.                 UnityPlayerNativeActivity.class);
    Then on function SetNotification,I change
    Code (CSharp):
    1. am.set(0, System.currentTimeMillis() + delay,
    2.                 PendingIntent.getBroadcast(currentActivity, id, intent, 0));
    To
    Code (CSharp):
    1. am.set(0, System.currentTimeMillis() + delay,
    2.                 PendingIntent.getBroadcast(currentActivity, id, intent, PendingIntent.FLAG_UPDATE_CURRENT));
     
  38. Hushe

    Hushe

    Joined:
    Mar 30, 2015
    Posts:
    5
    Thanks for this plugin. It works fine when I build the example you provided, but I am getting a problem when I integrate it into my project which is also using the Facebook plugin.

    The problem I am getting is that the notifications result in no message, but the alarm bell sounds, and they can be repeated and cancelled (but only resulting in alarm bells).

    This is how I have integrated the AndroidManifest.xml:
    Code (JavaScript):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest
    3.     xmlns:android="http://schemas.android.com/apk/res/android"
    4.     package="com.unity3d.player"
    5.     android:installLocation="preferExternal"
    6.     android:versionCode="1"
    7.     android:versionName="1.0">
    8.  
    9.   <uses-permission android:name="android.permission.VIBRATE" />
    10.   <uses-sdk android:targetSdkVersion="22" android:minSdkVersion="15" />
    11.   <supports-screens
    12.       android:smallScreens="true"
    13.       android:normalScreens="true"
    14.       android:largeScreens="true"
    15.       android:xlargeScreens="true"
    16.       android:anyDensity="true" />
    17.    
    18.   <application
    19.       android:theme="@android:style/Theme.NoTitleBar"
    20.       android:icon="@drawable/app_icon"
    21.       android:label="@string/app_name"
    22.       android:debuggable="true">
    23.    
    24.     <activity
    25.         android:name="com.unity3d.player.UnityPlayerActivity"
    26.         android:label="@string/app_name">
    27.       <intent-filter>
    28.         <action android:name="android.intent.action.MAIN" />
    29.         <category android:name="android.intent.category.LAUNCHER" />
    30.         <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
    31.       </intent-filter>
    32.       <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    33.       <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    34.     </activity>
    35.  
    36.     <activity
    37.         android:name="com.facebook.unity.FBUnityLoginActivity"
    38.         android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    39.         android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
    40.     </activity>
    41.  
    42.     <activity
    43.         android:name="com.facebook.unity.FBUnityDialogsActivity"
    44.         android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    45.         android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
    46.     </activity>
    47.     <activity
    48.         android:name="com.facebook.LoginActivity"
    49.         android:configChanges="keyboardHidden|orientation"
    50.         android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
    51.     </activity>
    52.     <activity
    53.         android:name="com.facebook.unity.FBUnityDeepLinkingActivity"
    54.         android:exported="true">
    55.     </activity>
    56.     <meta-data
    57.         android:name="com.facebook.sdk.ApplicationId"
    58.         android:value="\ 123456789012345" /> <!-- not the real application id -->
    59.  
    60.     <!-- NOTIFY java -->
    61.     <receiver android:name="net.agasper.unitynotification.UnityNotificationManager"></receiver>
    62.     <!-- end -->
    63.   </application>
    64. </manifest>
    I read some of the comments above and changed line 9 in LocalNotification.cs to:
    Code (CSharp):
    1. private static string unityClass = "com.unity3d.player.UnityPlayerActivity";
    But this only results in the bell sounding.

    I am sure there is a simple fix just around the corner, as it works fine in the example, showing the message as well as playing the alarm.

    Any help would be greatly appreciated.

    Thanks
     
  39. AnikKhoma

    AnikKhoma

    Joined:
    Apr 10, 2014
    Posts:
    10
    On Android 4.0.3 i has got this:
    Code (CSharp):
    1. I/dalvikvm(10317): Could not find method android.app.Notification$Builder.setColor, referenced from method net.agasper.unitynotification.UnityNotificationManager.onReceive
    2.  
    3. W/dalvikvm(10317): VFY: unable to resolve virtual method 37: Landroid/app/Notification$Builder;.setColor (I)Landroid/app/Notification$Builder;
    4.  
    5. D/dalvikvm(10317): VFY: replacing opcode 0x6e at 0x00eb
    6.  
    7. I/dalvikvm(10317): Could not find method android.app.Notification$Builder.build, referenced from method net.agasper.unitynotification.UnityNotificationManager.onReceive
    8.  
    9. W/dalvikvm(10317): VFY: unable to resolve virtual method 35: Landroid/app/Notification$Builder;.build ()Landroid/app/Notification;
    10.  
    11. D/dalvikvm(10317): VFY: replacing opcode 0x6e at 0x01a4
    12.  
    13. W/dalvikvm(10317): threadid=1: thread exiting with uncaught exception (group=0x40ab5228)
    14.  
    15. W/ActivityManager( 1604):   Force finishing activity net.agasper.notificationtest/com.unity3d.player.UnityPlayerNativeActivity
    16.  
    17. W/ActivityManager( 1604): Activity pause timeout for ActivityRecord{41219168 net.agasper.notificationtest/com.unity3d.player.UnityPlayerNativeActivity}
    18.  
    19. I/ActivityManager( 1604): Process com.htc.bgp (pid 10218) has died.
    20.  
    21. I/ActivityManager( 1604): Process net.agasper.notificationtest (pid 10317) has died.
    22.  
    23.  
    You do not support version 4.0.3?
    Why this condition not working? Or problem is in other place? (i'm not java/android coder)
    Code (CSharp):
    1. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    2.             builder.setColor(color);
    Sory for my horrible English:)
     
    Last edited: Jul 31, 2015
  40. Hushe

    Hushe

    Joined:
    Mar 30, 2015
    Posts:
    5
    Hi AnikKhoma,

    I am getting exactly the same problem. I suspect it may have something to do with the current Android SDK we have installed. I'm looking into it and will post any solution here if I find one.

    Edit:

    I think I have identified the cause for my situation: I was calling

    Code (CSharp):
    1. LocalNotification.CancelNotification(1);
    before re-using that id for my SendNotification. Apparently this was the cause of the setColor crash, which is misleading. The problem went away when I did not call CancelNotification beforehand. I will probably implement a flag to check whether there is a pre-existing notification to cancel.
     
    Last edited: Aug 3, 2015
  41. AnikKhoma

    AnikKhoma

    Joined:
    Apr 10, 2014
    Posts:
    10
    Hi, Hushe,
    I'm just pressing "5 SEC" button in test scene, and after 5 seconds i got this error
    If pressing a "5 SEC REPEAT" button, application also falls, and then no longer starting, falling with the same error
    Probably the most effective solution for me is to remove the "SetColor" feature :)
     
  42. yhiroki

    yhiroki

    Joined:
    Jul 1, 2015
    Posts:
    2
    Hi, Hushe,

    I am getting exactly the same problem. How to check whether there is a pre-existing notification to cancel?
     
  43. Balours

    Balours

    Joined:
    Nov 27, 2013
    Posts:
    59
    Hi Nihilitik,

    Nothing happens when I call a notification, I think this is related to the android manifest ...
    I'm using, UnityAds, Google Play Games and your plugins, the others work perfectly.
    I've no idea where is located the merged manifest file, there is nothing in plugins/android.

    What can I do ?
     
    Last edited: Aug 23, 2015
  44. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    @Nihilitik lol it was my fault. I don't know how but it worked for me this time. This is real awesome :D
     
  45. InnerVoice

    InnerVoice

    Joined:
    Mar 6, 2013
    Posts:
    1
    Hi, Nihilitik. Thank you for your plugin, it works great! I've faced some troubles with unity activity class name, so I ended up with this solution:
    Code (CSharp):
    1. intent.putExtra("unityClass", UnityPlayer.currentActivity.getClass().getName());
    instead of using predefined unityClass string
    Code (CSharp):
    1. intent.putExtra("unityClass", unityClass);
    Haven't found any problems with it yet. Hope it will be helpful for somebody.
     
  46. CLazaroS

    CLazaroS

    Joined:
    Aug 23, 2015
    Posts:
    1
    Hi, @Hushe.
    I have the same problem that you had. I only receive a Alarm and vibration but I don't receive any message.
    I have tried the solution that you said: Sending "CancelNotification" only when you have sent a notification, but it still doesn't work for me.

    Any ideas??
    Thanks
     
  47. yyhuang

    yyhuang

    Joined:
    Nov 3, 2014
    Posts:
    3
    There is a bug in Unity5 which will cause only vibration but no message notification. The bug is fixed in Unity5.2.1p3.
     
  48. Nasir41

    Nasir41

    Joined:
    Nov 11, 2015
    Posts:
    3
    Thanx for this help working great for me :)
     
  49. Nasir41

    Nasir41

    Joined:
    Nov 11, 2015
    Posts:
    3
    Working great but can I implement some method to know if my application is opened normal or after clicking on these notifications..
    I just want to track how many user came back after clicking on notification..
     
  50. erpresi

    erpresi

    Joined:
    Oct 28, 2014
    Posts:
    7
    Hello,

    First of all, THANKS!!!! It works great and it is super easy to implement.

    I'm having problems to get the message on the notification, the title appears but not the message. I'm using Unity5.2.2, Anyone have any way to solve it? I tried in Android 4.4, Android 5.0 and Android 5.1, same result on all.

    Edit: I updated the plugin (LocalNotification.cs and Notification.jar) with the one released a few days ago and it is still happening.

    Thanks