Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Free Android local notifications plugin open source

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

  1. swtfustarkiller

    swtfustarkiller

    Joined:
    Jul 8, 2013
    Posts:
    1
  2. cramz49

    cramz49

    Joined:
    Jan 7, 2016
    Posts:
    3
    How can i open this project? once i click the file in Assets folder called "NotificationTest" the file is not opening.

    Edit:
    I've already opened the app and its working but it is only Vibrating and no message notification how can i make it work?
     
    Last edited: Jan 21, 2016
  3. cramz49

    cramz49

    Joined:
    Jan 7, 2016
    Posts:
    3
    Hello!

    I have a problem with "OBSOLETE - Providing Android resources in Assets/Plugins/Android/res is deprecated, please move your resources to an Android Library. See "Building Plugins for Android" section of the Manual." and i read your note how to fix it. but i'm really new in Unity i don't know what you mean by "You can avoid this by recompiling plugin with icons inside.". I really don't get it.

    Update: I have fix it..

    2nd Problem is There is no sound in my notification it only vibrate how can put some sound to it?

    Any answer would help thanks!
     
    Last edited: Jan 23, 2016
  4. LexPanin

    LexPanin

    Joined:
    Jan 10, 2016
    Posts:
    12
    Hi,
    Thanks for your work. All work well. I have one question - is there a way to show notification when application is shut down?
     
  5. Mootinator

    Mootinator

    Joined:
    May 13, 2015
    Posts:
    3
    Hi,

    Thanks a lot for this plugin it is working as intended great!!

    My question is has anyone been able to successfully relaunch their app by clicking on this alarm? I have tried to pass the activity via the pendingIntent but am unsuccessful.

    Any help would be great!
     
  6. tanveerm

    tanveerm

    Joined:
    Feb 24, 2016
    Posts:
    22
    @Nihilitik, this is a simple plugin for Android, However we are getting so many crashes from this plugin, I'm using Unity5.3.5p7 pro version. Here is the log if that helps you debug.

    Caused by java.lang.RuntimeException: Unable to start receiver net.agasper.unitynotification.UnityNotificationManager: java.lang.NullPointerException
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3022)
    at android.app.ActivityThread.access$1800(ActivityThread.java:177)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1511)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5930)
    at java.lang.reflect.Method.invoke(Method.java)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
    Caused by java.lang.NullPointerException
    at java.lang.Class.classForName(Class.java)
    at java.lang.Class.forName(Class.java:309)
    at java.lang.Class.forName(Class.java:273)
    at net.agasper.unitynotification.UnityNotificationManager.onReceive(UnityNotificationManager.java:95)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3015)
    at android.app.ActivityThread.access$1800(ActivityThread.java:177)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1511)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5930)
    at java.lang.reflect.Method.invoke(Method.java)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
     
  7. HadesKratos

    HadesKratos

    Joined:
    Oct 27, 2016
    Posts:
    1
    hey im tottaly new but i created a unity mobile game for android . The thing is i wanna put the repeat codes on void start() so when i start the app the code will be activated but i also want it to repeat randomly like random notifications . But it dosent work . can you help implement my codes i hope you got the idea of it .

    here's an example


    voidstart ()
    {
    for (inti = 0; i = 50; i++) {

    num = Random.Range(1123,2231,33412,43312,52341,623442);

    LocalNotification.SendRepeatingNotification(1, num, 5, "Title", "send in" + num + " seconds", newColor32(0xff, 0x44, 0x44, 255));
    sleepUntil = Time.time + 99999;
    }


    }
     
  8. tanveerm

    tanveerm

    Joined:
    Feb 24, 2016
    Posts:
    22
    Hi Nihilitik,
    I'm Having issues with notification not opening the app,

    Here is my adnroid manifest file:

    <?xml version="1.0"?>
    <manifest android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0" package="com.unity3d.player" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="com.android.vending.BILLING" />
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" />
    <application android:debuggable="false" android:icon="@drawable/app_icon" android:label="@String/app_name" android:name="io.fabric.unity.android.FabricApplication">
    <activity android:configChanges="orientation|screenLayout|screenSize|smallestScreenSize" android:name="com.prime31.EtceteraProxyActivity">
    </activity>
    <activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="com.prime31.WebViewActivity">
    </activity>
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.prime31.P31VideoPlayerActivity">
    </activity>
    <receiver android:name="com.prime31.AlarmManagerReceiver">
    </receiver>
    <activity android:name="com.unity3d.plugin.downloader.UnityDownloaderActivity" />
    <service android:name="com.unity3d.plugin.downloader.UnityDownloaderService" />
    <receiver android:name="com.unity3d.plugin.downloader.UnityAlarmReceiver" />
    <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.ads.AdActivity" />
    <activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:configChanges="keyboardHidden|orientation" android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb1161740457207072" />
    <activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
    <activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
    <activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
    <activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
    <activity android:name="com.facebook.unity.AppInviteDialogActivity" />
    <provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider1161740457207072" android:exported="true" />
    <meta-data android:name="billing.service" android:value="google.GooglePlayIabService" />
    <!-- FYBER PLUGIN RELATED -->
    <!-- SponsorPay OfferWall Activity -->
    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:name="com.sponsorpay.publisher.ofw.SPOfferWallActivity" android:screenOrientation="sensor" />
    <!-- SponsorPay Mobile BrandEngage Activity -->
    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:hardwareAccelerated="true" android:name="com.sponsorpay.unity.SPBrandEngageUnityActivity" />
    <!-- SponsorPay Interstitial Activity -->
    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:hardwareAccelerated="true" android:name="com.sponsorpay.publisher.interstitial.SPInterstitialActivity" />
    <!-- SponsorPay Wrapper Activity -->
    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:name="com.sponsorpay.unity.SPWrapperActivity" />
    <!-- SponsorPay Pre-caching service -->
    <service android:exported="false" android:name="com.sponsorpay.publisher.mbe.player.caching.SPCacheVideoDownloadService" />
    <meta-data android:name="com.google.android.gms.version" android:value="@Integer/google_play_services_version" />
    <meta-data android:name="applovin.sdk.key" android:value="DyuU00cV5Q7xzWw9EKO5UNkMNkZ0v9A662b63Db8dk4bF-lTJ7ToUG8t_htus2_z4b37pfGROL2dKn5dveQOwZ" />
    <activity android:name="com.applovin.adview.AppLovinInterstitialActivity" />
    <activity android:name="com.applovin.adview.AppLovinConfirmationActivity" />
    <activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="com.vungle.publisher.FullScreenAdActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
    <activity android:configChanges="orientation|screenSize" android:name="com.fyber.unity.ads.OfferWallUnityActivity" />
    <activity android:configChanges="screenSize|orientation" android:hardwareAccelerated="true" android:name="com.fyber.unity.ads.RewardedVideoUnityActivity" android:theme="@android:style/Theme.Translucent" />
    <activity android:configChanges="screenSize|orientation" android:name="com.fyber.unity.ads.InterstitialUnityActivity" android:theme="@android:style/Theme.Translucent" />
    <service android:exported="false" android:name="com.fyber.cache.CacheVideoDownloadService" />
    <activity android:name="com.inmobi.androidsdk.IMBrowserActivity" android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" android:hardwareAccelerated="true" />
    <!-- allows for optimization of ad delivery -->
    <service android:name="com.inmobi.commons.internal.ActivityRecognitionManager" android:enabled="true" />
    <activity android:name="com.mediabrix.android.service.AdViewActivity" android:configChanges="orientation|screenSize|keyboard" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.fyber.mediation.mediabrix.rv.MediaBrixVideoHelperActivity" android:configChanges="orientation|screenSize|keyboard" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <service android:name="com.mediabrix.android.service.MediaBrixService" />
    <!-- FYBER PLUGIN RELATED -->
    <receiver android:name="net.agasper.unitynotification.UnityNotificationManager" />
    <activity android:label="@String/app_name" android:name="com.unity3d.player.UnityPlayerActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
    </intent-filter>
    <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
    </activity>
    <receiver android:exported="true" android:name="com.adjust.sdk.AdjustReferrerReceiver">
    <intent-filter>
    <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
    </receiver>
    <!-- ELAN NOTIFICATION -->
    <service android:enabled="true" android:name="com.CFM.ELAN.ELANAlarmCreator" />
    <receiver android:name="com.CFM.ELAN.TimedAlarm" />
    <!-- DELTA PUSH NOTIFICATION PARAMETERS -->
    <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
    <intent-filter>
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    <category android:name="com.cosiproductions.pele2" />
    </intent-filter>
    </receiver>
    <!-- push notifications -->
    <!--<service android:name="com.deltadna.android.sdk.notifications.NotificationListenerService" android:exported="false">
    <intent-filter>
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
    </service>-->
    <!-- push notifications -->
    <meta-data android:name="ddna_sender_id" android:resource="@String/sender_id" />
    <meta-data android:name="ddna_notification_icon" android:value="notify_icon_small" />
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
    <!-- DELTA PUSH NOTIFICATION PARAMETERS -->
    <activity android:name="com.soomla.store.billing.google.GooglePlayIabService$IabActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.fyber.ads.interstitials.InterstitialActivity" android:configChanges="screenSize|orientation" android:theme="@android:style/Theme.Translucent" />
    <activity android:name="com.fyber.utils.testsuite.TestSuiteActivity" android:label="Integration Test Suite" />
    </application>
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.unity3d.player.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="com.android.vending.CHECK_LICENSE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    </manifest>
     
  9. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Not really the answer you're asking for but, I've just implemented OneSignal (as mentioned elsewhere in this thread) and IMO it's so good, toying with any other solution would be insanity :)

    It's 100% free, feature packed, fast and has an excellent API. Takes a few minutes to get working and works great.
     
  10. Sushiy

    Sushiy

    Joined:
    Dec 7, 2014
    Posts:
    1
    Hey!
    Sorry this is probably a noobquestion but how do I even add this to my project? I tried just adding the "notification.jar" but can't seem to get it to work.

    On a sidenote I also can't get your example to work at all :(
     
  11. danielheadbang

    danielheadbang

    Joined:
    Mar 24, 2015
    Posts:
    34
    I love this plugin but I cannot get the notification action to work, either creating the OnAction(string identifier) or another handler method and changing the action handlermethod

    Can anyone do this and tell me what I'm doing wrong?


    Code (CSharp):
    1. public void SendNotification()
    2. {
    3.         // #if UNITY_ANDROID
    4.         LocalNotification.Action foreground = new LocalNotification.Action("Foreground", "In foreground", this);
    5.         LocalNotification.Action testo = new LocalNotification.Action("Testico", "this is a test", this);
    6.         testo.HandlerMethod = "Happen";
    7.         testo.Foreground = false;
    8.  
    9.         LocalNotification.Action[] actions = new LocalNotification.Action[] { foreground, testo };
    10.  
    11.         LocalNotification.SendNotification(1, testTimespan, "test title", "test message", new Color32(),actions: actions);
    12. }
    13. static void OnAction(string identifier)
    14.     {
    15.         Debug.Log("Got action " + identifier);
    16.         Debug.LogError("Got action " + identifier);
    17.     }
    18.  
    19.     static void Happen(string identifier)
    20.     {
    21.         Debug.Log("Got action " + identifier);
    22.         Debug.LogError("Got action " + identifier);
    23.     }
    24.  
     
  12. Amir-Khan

    Amir-Khan

    Joined:
    Jul 1, 2015
    Posts:
    3

    Hi tripwire!

    it is not working here, although i have followed every thing you have, i fire notification on button click but its not working and after SendRepeatingNotification(1, date01, Language.Get("Notification_Header01"), no line of code is compiled, means there is error in calling this function.
    Also i have changed unityClass name in LocalNotification class to:

    private static string unityClass = "com.unity3d.player.UnityPlayerActivity";

    Please help me out if i m making mistakes
     
  13. masoudarvishian

    masoudarvishian

    Joined:
    Jan 15, 2015
    Posts:
    9
    No notification on Android 7.0!
     
  14. Lampogolovii_

    Lampogolovii_

    Joined:
    Aug 28, 2017
    Posts:
    12
    How can I add a button to the notification? (like "play/pause" button for music player)
     
  15. tarunsingh013

    tarunsingh013

    Joined:
    Jun 12, 2018
    Posts:
    7
    Can someone please tell me, how do I integrate it into my current app? Import package, asset or what?
    Please help.
     
  16. danielheadbang

    danielheadbang

    Joined:
    Mar 24, 2015
    Posts:
    34
    Download the source code from the repository and add the Assets folder insides to your Asset folder for your project

    That should do it
     
    tarunsingh013 likes this.
  17. tarunsingh013

    tarunsingh013

    Joined:
    Jun 12, 2018
    Posts:
    7
    Thanks @danielheadbang
    Btw, can we send an image (to show as a banner) along with the notification?
     
  18. danielheadbang

    danielheadbang

    Joined:
    Mar 24, 2015
    Posts:
    34
    I don't remember if that was an option actually, if I'm not mistaken if was done with an image of a specific set of width and height in the streaming assets folder, but maybe I'm confusing it with another notification asset