wumke / react-native-local-notifications Goto Github PK
View Code? Open in Web Editor NEWManageable local notifications for React Native on iOS and Android.
License: MIT License
Manageable local notifications for React Native on iOS and Android.
License: MIT License
while building it give an error
.........\MainActivity.java:19: error: cannot find symbol
NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
MainActivity.java:19: error: cannot find symbol
NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
MainActivity.java
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "gymcrumbs";
}
@Override
public void onResume() {
super.onResume();
NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nMgr.cancelAll();
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
"react": "^16.2.0",
"react-native": "^0.54.4",
RNLocalNotifications.createNotification(
1,
"Some text",
"2018-10-12 12:26",
"default"
);
If I run the app in the background it stops at exactly 12:26 ,
If the app is open nothing happens
Using react native version 0.59
I defined a notification as shown below then wait it to be displayed but app crashes.
RNLocalNotifications.createNotification(1, 'Some text', '2019-09-07 23:15', 'default');
Maybe the AlarmManager.cancel call should be inside the if !null statement
cancel() called with a null PendingIntent
cancel
AlarmManager.java:890
deleteAlarm
RNLocalNotificationsModule.java:118
createAlarm
RNLocalNotificationsModule.java:63
updateNotification
RNLocalNotificationsModule.java:50
invoke
Method.java
invoke
JavaMethodWrapper.java:372
invoke
JavaModuleWrapper.java:160
run
NativeRunnable.java
handleCallback
Handler.java:751
dispatchMessage
Handler.java:95
dispatchMessage
MessageQueueThreadHandler.java:29
loop
Looper.java:154
run
MessageQueueThreadImpl.java:192
run
Thread.java:761
I installed it as described:
Check dependencies
Unable to run command 'Libtool libRNLocalNotifications.a' - this target might include its own product.
** BUILD FAILED **
The package is working great on iOS for us, however, there is a problem with Android whereby it causes a fatal exception and crashes the app.
This is the output of LogCat at the time of the exception
2019-07-09 13:10:00.926 28607-28607/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.busbynative:remote, PID: 28607
java.lang.RuntimeException: Unable to start receiver com.github.wumke.RNLocalNotifications.AlarmReceiver: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(pri=0 contentView=null vibrate=[0,1000] sound=content://settings/system/notification_sound defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3039)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(pri=0 contentView=null vibrate=[0,1000] sound=content://settings/system/notification_sound defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE)
at android.app.NotificationManager.notifyAsUser(NotificationManager.java:306)
at android.app.NotificationManager.notify(NotificationManager.java:284)
at android.app.NotificationManager.notify(NotificationManager.java:268)
at com.github.wumke.RNLocalNotifications.AlarmReceiver.onReceive(AlarmReceiver.java:131)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
We are invoking the notification with the following:
// Manual test notification
RNLocalNotifications.createNotification(
1,
"Incident notification",
"2019-07-09 13:10",
"busby"
);
We are using react-native 0.59.10 and have followed all of the installation instructions to the letter. Any ideas on this one?
The readme says: The date + time to show the notification, as a string in the format 'yyyy-mm-dd hh:mm'
And indeed I am not able to add seconds. Is there a reason for this limitation ? From the Apple docs I understand that seconds (even milliseconds) should be possible ?
I want to use local notifications for timing sub-minute events. So its important to have seconds support and I wonder if that is possible at all.
Hi, first of all thank you for this plugin.
I have a problem with custom notification sounds. When I debug the code, I can see my custom mp3 is resolved in resources.
https://i.imgsafe.org/c7/c7c04bd67c.png
But in logcat, I see this error,
E/OMXNodeInstance: setConfig(0xe5d26c00:google.vorbis.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
and the device plays default notification sound.
Any help is appreciated.
Only the sound is played without the registered message being displayed.
I registered as below.
RNLocalNotifications.createNotification (10, 'Some text', '2017-07-03 00:19', 'default');
I use react-native-push-notification, for handle onNotification event to get hiddendata. Works fine on ios but on android onNotification method not trigger.
Thanks
Is there a way to remove or delete a scheduled local notification?
Thank you.
Hello i was just installed this plugin, i set the code to
RNLocalNotifications.createNotification(1,'Some Text', '2018-02-15 21:05', 'default');
but nothing happens at that time, i just set the app to background (i mean i pressed the home button) then no notification appear, also, i haven't receive the warning of "Do you want to receive notifications?"
any idea?
RN v : 0.53.0
device : iPhone 8 Simulator (yes, you can receive local notification here)
platform : Mac
Wow! This is working smoothly. I want to set repeatInterval?
I see in the readme we can provide data to createNotification/updateNotification parameter.
How to get that hiddendata from rn component?
Thanks
Virsions
"react-native": "^0.47.1",
"react-native-local-notifications": "^0.1.0",
Error
:react-native-local-notifications:compileReleaseJavaWithJavac
:react-native-local-notifications:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\web\apps\reactnative\demonotify\node_modules\react-native-local-notifications\android\src\main\java\com\github\wumke\RNLocalNotifications\RNLocalNotificationsPackage.java:26: error: method does not override or implement a method from a supertype
@Override
^
1 error
:react-native-local-notifications:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-local-notifications:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Followed all the steps exactly and the build fails because of the code you instruct users to add into MainActivity.java
:
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/www/apps/Slick/android/app/src/main/java/com/itsahappymedium/slick/MainActivity.java:19: error: cannot find symbol
NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
^
symbol: class NotificationManager
location: class MainActivity
/www/apps/Slick/android/app/src/main/java/com/itsahappymedium/slick/MainActivity.java:19: error: cannot find symbol
NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
^
symbol: class NotificationManager
location: class MainActivity
/www/apps/Slick/android/app/src/main/java/com/itsahappymedium/slick/MainActivity.java:19: error: cannot find symbol
NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
^
symbol: variable Context
location: class MainActivity
3 errors
:app:compileDebugJavaWithJavac FAILED
Hello,
Is it easily possible to have a more custom notification design ? I need some buttons and events in my notification.
I'm not from java, I managed to do it in a pure java project, but can't find where to put my files to make it working with react-native.
Thanks
node version: 10:14:1
react-native version: 0.57.8
android version: lollipop 5.1
I am getting error in MainActivity.java when i run react-native run-android
NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
error is in Context
then i remove Context, working fine but local notification is not triggering.
I followed step by step procedure, everything is fine. Please let me know about this issue.
Thanks.
I used RNLocalNotifications.createNotification(1, 'Some text', '2017-01-02 12:30', 'default');
in my componentwillmount component. Local notifications are not triggering.
@wumke I'm using react native v0.60.5 "react native link" is not used anymore to link component, when trying to run it in xcode the following error appears:
'RCTBridgeModule.h' file not found
is there any way to link react-native-local-notifications using cocoapods or how can we fix this issue?
react-native": "0.60.5",
"react-native-local-notifications": "2.0.0"
when the step 1 is executed : "Add RNLocalNotifications.xcoderproj into your project in the Libraries folder." exist a compiled erro /node_modules/react-native-local-notifications/ios/RNLocalNotifications/RNLocalNotifications.m:2:9: 'RCTBridgeModule.h' file not found
(Future releases: your own custom sounds, name-based!)
Any idea when this future arrives ? ;-)
Is it much work for you to implement this ?
I want to play a sound file that I created myself.
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.