agasper / unity-android-notifications Goto Github PK
View Code? Open in Web Editor NEWUnity3D Plugin for Android local notifications with example project
License: Other
Unity3D Plugin for Android local notifications with example project
License: Other
Hi Guys! Just found this problem. I've already follow every step from this github. When I try on an empty project, it worked perfectly. Can it do something with another plugin / plugin conflict? or something wrong in manifest? Or are there any reasons? Please help. I'm so desperate. Thank you
Below is my androidmanifest
(can't upload xml file here)
Does anyone know the issue [Notification doesn't launch the app] how to set in AndroidManifest.xml ??
Original description:
Set LocalNotification.mainActivityClassName to the your main activity class (from manifest)
First, let me say that this is a great and highly useful project!
I'm having problems with integrating it due to support-v4 issues - despite adding it through dependencies in Android Studio I'm still getting errors and crashes.
To make this work, I removed all references to support-v4 classes (like android.support.v4.app.NotificationCompat and android.support.v4.app.TaskStackBuilder), and managed to get the plugin to work, but it is clearly a hack.
Two questions:
Hi Agasper Team.I want to limit number of time push every day only have 2 times.How to count number of times push?.Can you suggestion for me? Thank you so much.
hey, i got a problem when try launching notif when the app is not active
when i launch the app the notif can come out fine, but not when its off
i use unity 5.2.3 , and the got the exact manifest like yours
i only run the SendRepeatingNotification once on start function with 10 seconds delay
heres the logcat:
--------- beginning of /dev/log/system
W/BroadcastQueue( 478): Unable to launch app bundleIDhere/10183 for broadcast Intent { flg=0x14 cmp=bundleIDhere>/net.agasper.unitynotification.UnityNotificationManager (has extras) }: process is bad
V/AlarmManager( 478): triggered: flg=0x14
V/AlarmManager( 478): Pkg: bundleIDhere
W/BroadcastQueue( 478): Unable to launch app bundleIDhere/10183 for broadcast Intent { flg=0x14 cmp=bundleIDhere>/net.agasper.unitynotification.UnityNotificationManager (has extras) }: process is bad
V/AlarmManager( 478): triggered: flg=0x14
V/AlarmManager( 478): Pkg: bundleIDhere
W/BroadcastQueue( 478): Unable to launch app bundleIDhere/10183 for broadcast Intent { flg=0x14 cmp=bundleIDhere>/net.agasper.unitynotification.UnityNotificationManager (has extras) }: process is bad
V/AlarmManager( 478): triggered: flg=0x14
V/AlarmManager( 478): Pkg: bundleIDhere
how do i fix it?
thank you in advance
tried some variations of this plugin. thats perfect. but i got an issue. created a new notification with 10secs delay and closed application(not exit, only pause). after 10 seconds, app crashed. logs are bellow. thanks.
E/AndroidRuntime(10937): Process: com.omr, PID: 10937
E/AndroidRuntime(10937): java.lang.Error: FATAL EXCEPTION [main]
E/AndroidRuntime(10937): Unity version : 5.0.0f4
E/AndroidRuntime(10937): Device model : asus Nexus 7
E/AndroidRuntime(10937): Device fingerprint: google/razor/flo:5.1/LMY47O/1783956:user/release-keys
E/AndroidRuntime(10937):
E/AndroidRuntime(10937): Caused by: java.lang.RuntimeException: Unable to start receiver net.agasper.unitynotification.UnityNotificationManager: java.lang.NullPointerException
E/AndroidRuntime(10937): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2616)
E/AndroidRuntime(10937): at android.app.ActivityThread.access$1700(ActivityThread.java:151)
E/AndroidRuntime(10937): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
E/AndroidRuntime(10937): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(10937): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(10937): at android.app.ActivityThread.main(ActivityThread.java:5254)
E/AndroidRuntime(10937): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10937): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(10937): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
E/AndroidRuntime(10937): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
E/AndroidRuntime(10937): Caused by: java.lang.NullPointerException
E/AndroidRuntime(10937): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(10937): at java.lang.Class.forName(Class.java:309)
E/AndroidRuntime(10937): at java.lang.Class.forName(Class.java:273)
E/AndroidRuntime(10937): at net.agasper.unitynotification.UnityNotificationManager.onReceive(UnityNotificationManager.java:88)
It works for me when play or in the foreground. But i want it can receive when the app is closed.
Can you help me ?
java.lang.RuntimeException: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2566) at android.app.ActivityThread.access$1800(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5457) at java.lang.reflect.Method.invokeNative(Native Method:0) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:879) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695) at dalvik.system.NativeStart.main(Native Method:0) Caused by: java.lang.SecurityException: at android.os.Parcel.readException(Parcel.java:1434) at android.os.Parcel.readException(Parcel.java:1388) at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:320) at android.app.NotificationManager.notify(NotificationManager.java:136) at android.app.NotificationManager.notify(NotificationManager.java:109) at net.agasper.unitynotification.UnityNotificationManager.onReceive(UnityNotificationManager.java:134) at android.app.ActivityThread.handleReceiver(ActivityThread.java:2555)
I have been seeing a lot of crashes due to above issue on Android, any solution for it?
Is it possible to use only big icon in notification and don't use the small icon?
Or at least make the small icon transparent?
I've tried to remove the small icon parameter, but it make the app not working. And then I tried to give the small icon a transparent image, but there is a background color around it. I've also tried to change the number in Color32, but the result only change the background color, and not make it transparent.
Thank you.
If I remove [res] folder from Plugins (as it's obsolete) and put all icons to [jar] - notifications will no be displayed (you hear sound only).
I'm getting crash in example project. I opened project as it is and added NotificationTest.cs to MainCamera, and the app crashes at time when the notification should appear.
Notifications are firing but we are unable to get text and icon, only vibration and tune is ringing
When I tried to run this exact application, without any modifications, I am getting a crash when I am receiving local notifications on my Kindle Fire device. I see no issues anywhere, yet I am not able to resolve this issue. Maybe, it got something to with the manifest file. I appreciate any suggestions.
hi
is it possible to send group notifications? like WhatsApp and Telegram?
Hi, Its really very nice, Thanks for it. I placed the Schedule repeat notification. After opened the game first time its starts working. its works fine after i closed my game. If i restart my phone then its stop working.
Hello Everyone,
I am using this in Unity game, Notification works fine but the Notification doesn't launch the app, Please help thanks in advace
Hi,
I am trying to create Unity application that shows notification in statusbar. The application should be launched by tap on notification. When i tap in notification message bar, it's only remove without open?
Can you give me some idea to fix this problem? hope your feed back soon, thanks.
Below is my android manifest.xml:
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
<!-- android:debuggable should be removed in release build -->
<application
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:debuggable="true">
<activity android:name="com.unity3d.player.UnityPlayerProxyActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
</activity>
<!-- NOTIFY java -->
<receiver android:name="net.agasper.unitynotification.UnityNotificationManager"></receiver>
<!-- end -->
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>
<activity android:name="org.onepf.openiab.UnityProxyActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
</activity>
<receiver android:name="com.amazon.device.iap.ResponseReceiver">
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
</intent-filter>
</receiver>
</application>
<!--Fortumo start-->
<receiver android:name="mp.MpSMSReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<service android:name="mp.MpService" />
<service android:name="mp.StatusUpdateService" />
<activity
android:name="mp.MpActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
could you add payload string to go with the notification
I could add notification id so i can check it as a payload
notificationIntent.putExtra("id",id);
This will get the data if application starts with the notification
AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activityObject = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject intent = activityObject.Call<AndroidJavaObject>("getIntent");
intent.Call<int>("getIntExtra", "id",0)
But i can't find a way to get this if the application is allready running when the notification is clicked
use
PendingIntent.getBroadcast(currentActivity, id, intent, PendingIntent.FLAG_UPDATE_CURRENT)
instead of
PendingIntent.getBroadcast(currentActivity, id, intent, 0)
see:
https://stackoverflow.com/questions/18649728/android-cannot-pass-intent-extras-though-alarmmanager
Well, when notification is clicked it opens Google Photos I have checked the package name passed on notification is correct. Any way to fix it?
Steps for reproduce:
If you no call CancelNotification, everything is good.
Exception in line: unityClassActivity = Class.forName(unityClass); (Nullpointer)
Hello.
Today i tried your Plugin following:
do you know why?
Thanks.
Hello,
I'm attempting to only use the small icons, but on one of our devices (Nexus 5), the icon shows up as just white. I have all the small icons in the res/ folder at what I believe are the right sizes (I just used the same sizes you had, and the same sizes listed here http://iconhandbook.co.uk/reference/chart/android/). Have you seen this issue before? Any ideas how to fix it?
Greetings. I tried to build plugin with import source (from PlugInSrc folder) into empty activity template with using grudle, and thats seems legit, but there is some errors while i tired to complie unity projects.
Has anybody to able explain the better way how compile plugin sources into jar?
I want add emoji to text.
Can you help me?
Notification fires if app is open or minimized, if I totally close the app via Application Manger, I don't receive any scheduled notifications, is it correct behavior?
Tested with demo UnityProject on Android 4.4.2
Hello Everyone.I updated to unity to new version.When I quit game then game notification crashed.
I set Time about 20 secondes push notification.When I click title on bar android device and then game show crashed game.Please suggestion for me to solve this problems.
i have tried to edit the provided plugin with android builder.setstyle(new bigpicturestyle) method but new generated jar does not work. please suggest the best way to do this or provide the plugin with bigpicturestyle ,, please ..
After the build, notifications work, but vibration and alarm dont work.
What is the possible problem?
I did the test using HP8 and nexus4 with Android 5.1.1
Thank you for your cooperation. its nice!!
im using many android plugins
everyplay , and unity purchase etc...
currently plugin path like this => Plugins / Android / unitynotification.jar
but i want change like this => Plugins / Android / localPush / unitynotification.jar
" localPush " is name of root folder,
would you help me?
On this one version of Android, for some reason the notifications produced by this plugin are set to be sensitive content, which means that users who have the hide sensitive content when phone is locked option turned on only see a white icon and generic placeholder text.
It would be great to have explicit control over the sensitivity setting of each notification or, barring that, at least make sure that they default to public for all versions of Android.
Is it possible to make in sort that the notification is ignored if the app is open?
So it'll only work in background or when the app is closed
Thanks
only getting sound notification for the demo scene, not the visual in the notification bar at top of android
config
version : unity5.2
OS : Nexus 7 (2012), android 5.1.1
HI. If I change NotificationTest.cs class in your Test progect for this code:
public class NotificationTest : MonoBehaviour {
void OnApplicationPause(bool paused) {
if (paused)
EnableNotifications();
else
DisableNotifications();
}
void OnApplicationQuit() {
EnableNotifications();
}
void EnableNotifications() {
LocalNotification.SendNotification(1, 10, "Title", "Long exact message text", new Color32(0xff, 0x44, 0x44, 255), executeMode: LocalNotification.NotificationExecuteMode.ExactAndAllowWhileIdle);
}
void DisableNotifications() {
LocalNotification.CancelNotification(1);
}
}
Exception in Android logs:
02-12 11:20:01.221: E/AndroidRuntime(3595): FATAL EXCEPTION: main
02-12 11:20:01.221: E/AndroidRuntime(3595): java.lang.Error: FATAL EXCEPTION [main]
02-12 11:20:01.221: E/AndroidRuntime(3595): Unity version : 5.3.1f1
02-12 11:20:01.221: E/AndroidRuntime(3595): Device model : samsung GT-P5110
02-12 11:20:01.221: E/AndroidRuntime(3595): Device fingerprint: samsung/espresso10wifixx/espresso10wifi:4.2.2/JDQ39/P5110XXDMI1:user/release-keys
02-12 11:20:01.221: E/AndroidRuntime(3595): Caused by: java.lang.RuntimeException: Unable to start receiver net.agasper.unitynotification.UnityNotificationManager: java.lang.NullPointerException: name == null
02-12 11:20:01.221: E/AndroidRuntime(3595): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2448)
02-12 11:20:01.221: E/AndroidRuntime(3595): at android.app.ActivityThread.access$1600(ActivityThread.java:150)
02-12 11:20:01.221: E/AndroidRuntime(3595): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
02-12 11:20:01.221: E/AndroidRuntime(3595): at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 11:20:01.221: E/AndroidRuntime(3595): at android.os.Looper.loop(Looper.java:175)
02-12 11:20:01.221: E/AndroidRuntime(3595): at android.app.ActivityThread.main(ActivityThread.java:5279)
02-12 11:20:01.221: E/AndroidRuntime(3595): at java.lang.reflect.Method.invokeNative(Native Method)
02-12 11:20:01.221: E/AndroidRuntime(3595): at java.lang.reflect.Method.invoke(Method.java:511)
02-12 11:20:01.221: E/AndroidRuntime(3595): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
02-12 11:20:01.221: E/AndroidRuntime(3595): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
02-12 11:20:01.221: E/AndroidRuntime(3595): at dalvik.system.NativeStart.main(Native Method)
02-12 11:20:01.221: E/AndroidRuntime(3595): Caused by: java.lang.NullPointerException: name == null
02-12 11:20:01.221: E/AndroidRuntime(3595): at java.lang.Class.classForName(Native Method)
02-12 11:20:01.221: E/AndroidRuntime(3595): at java.lang.Class.forName(Class.java:217)
02-12 11:20:01.221: E/AndroidRuntime(3595): at java.lang.Class.forName(Class.java:172)
02-12 11:20:01.221: E/AndroidRuntime(3595): at net.agasper.unitynotification.UnityNotificationManager.onReceive(UnityNotificationManager.java:95)
02-12 11:20:01.221: E/AndroidRuntime(3595): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2441)
02-12 11:20:01.221: E/AndroidRuntime(3595): ... 10 more
When I try to call SendNotification function I get the next message :
(LocationNotification is obsolete: LocationNotification is deprecated. Please use iOS.LocalNotification instead (UnityUpgradable) -> UnityEngine.iOS.LocalNotification)
The problem is that I need to use on android device, not iOS.
If I am not wrong, I have to rebuild the plugin, but I'm new on this and I don't know how to do that.
Could anyone help me, please?
Thanks.
When i put 2 notifications, the second text is always show the text of the first. Can i missing something to remove cache ?
Hi there,
I've been using your plugin without problems for the past 2 or 3 months. But I have to implement another plugin (AppsFlyer) which overrides Unity's main activity. After that the app would crash every time it would try to display a notification. After some research I found out that I have to change the variable in C# to match the MAIN activity in my manifest. After doing it, it won't crash anymore but nothing will happen as well. I am not sure what I am doing wrong at this point and if you could take a look at my manifest that would be awesome because Im running out of ideas here.
Unity Version : 5.3.1p2 (pro)
Testing Phone : Android Galaxy S6 - Android version : 6.0.1
Manifest : http://pastie.org/private/3blkdbzl5pfnkzcqf1vdq
(git was giving me grief when putting the manifest here, so I just created a pastie)
C# changed: #if UNITY_ANDROID && !UNITY_EDITOR private static string fullClassName = "net.agasper.unitynotification.UnityNotificationManager"; private static string mainActivityClassName = "com.appsflyer.AppsFlyerOverrideActivity"; #endif
(nothing else was changed from your examples)
I think this info should be enough for you to have an idea of what is going on. Let me know if any more info is necessary and I'll send to you.
Cheers,
Cai
hello, i had add your plugin to my project, it's easy to use and awesome! but when i tap on notification message it's can't open the app?
Deleted the file unitynotification.jar from UnityProject\Assets\Plugins\Android
This file coflicts with notification.jar
Sup! How to call this task?
Hello!!
I have imported the android project in Android studio and tried building it using Gradle build tool. as a result, I got an Android .AAR file and it worked perfectly with unity.
Now, I'm trying to use new NotificationCompat.Builder in android code instead of Notification.Builder. but this requires using android-support-v4. this means that I should add a new dependency to gradle.build file to include the android support library inside my .AAR file which I did.
the problem is Gradle does not include the android-support-v4 in .AAR file and I cannot add the android-support-v4.jar to Unity. I would really appreciate any help.
I am working on project app using this plugin, but getting few issues
May not working on Android 6.
Pay attention to the AlarmManager usage: check 'set' and new 'setAndAllowWhileIdle' methods.
What do you think about moving PluginSrc to Android Studio?
Can I control through an option in my game whether or not my notifications vibrate?
Currently provided jar does not include method CancelAll, even though source code does, causing a RuntimeException if it is used. It would be very convenient if you could update the jar so that one would not have to rebuild the project.
I get this error if you use the plugin in unity 5.0 anyone know how to fix it?
Ignoring notification with icon==0: Notification(pri=0 contentView=net.agasper.notificationtest/0x10900b0 vibrate=null sound=null defaults=0x0 flags=0x10 kind=[null])
hey, thanks for the plugin
but could i work this as remote notif with GCM?
i'm sorry if its stupid question, but this is the first time i work with android notif with unity like this
thanks :D
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.