local notification not working!!
here is my code, componentDidMount(){ PushNotification.configure({ // (required) Called when a remote or local notification is opened or received onNotification: function(notification) { console.log( 'NOTIFICATION:', notification ); }, permissions: { alert: true, badge: false, sound: true }, popInitialNotification: true, requestPermissions: true, });
PushNotification.localNotification({ /* Android Only Properties */ id: '0', // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID ticker: "My Notification Ticker", // (optional) autoCancel: true, // (optional) default: true largeIcon: "ic_launcher", // (optional) default: "ic_launcher" smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher" bigText: "My big text that will be shown when notification is expanded", // (optional) default: "message" prop subText: "This is a subText", // (optional) default: none color: "red", // (optional) default: system default vibrate: true, // (optional) default: true vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000 tag: 'some_tag', // (optional) add tag to message group: "group", // (optional) add group to message ongoing: false, // (optional) set whether this is an "ongoing" notification priority: "high", // (optional) set notification priority, default: high visibility: "private", // (optional) set notification visibility, default: private importance: "high", // (optional) set notification importance, default: high alwaysFireSound: false, // (optional) will play sound even if phone is on silent or vibrate mode, default: false volume: 0.5, // (optional) volume of the notification sound. Will only work if "alwaysFireSound" is enabled soundPath: '', // (optional) local path of a sound, not necessarily within the app
/* iOS and Android properties */
title: "My Notification Title", // (optional)
message: "My Notification Message", // (required)
playSound: false, // (optional) default: true
soundName: 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
number: '10', // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
repeatType: 'day', // (optional) Repeating interval. Check 'Repeating Notifications' section for more info.
actions: '["Yes", "No"]', // (Android only) See the doc for notification actions to know more
}); }
same for me
Same for me
i've solved the issue doing the following:
- Downgrade to 3.1.1
- Run gradle clean
- Delete build folders (./android && ./android/app)
- Run react-native run-android again
Hope this works for you, at least temporally.
i've solved the issue doing the following:
- Downgrade to 3.1.1
- Run gradle clean
- Delete build folders (./android && ./android/app)
- Run react-native run-android again
Hope this works for you, at least temporally.
thx! works for me.
It works for me too. But now it seems the push notifications are not working, and they were working on the 3.1.2 version. Any tips on this? Thanks
Actually, push notifications just worked, but makes the app crash... before going back to the 3.1.1 it didn't crash.
I have the same problem that @pedrosimao . Any update? :(
@pedrosimao @danigm87 are you using react-native-background-job too?
i've solved the issue doing the following:
- Downgrade to 3.1.1
- Run gradle clean
- Delete build folders (./android && ./android/app)
- Run react-native run-android again
Hope this works for you, at least temporally.
Works for me too, thank you
Same problem on android devices any help please?
@imspikey give me more information about your problem Android version, lib version?
I had this same problem. I was using version 3.1.2, downgraded to version 3.1.1 and worked for me.
I'm using Android 9.
PushNotificationAndroid.configure({
onNotification: notification => {
console.log(notification);
},
requestPermissions: true,
});
PushNotificationAndroid.localNotificationSchedule({
title,
message,
date,
});
@slavikdenis the problem isn't gradle, is the lib, im using gradle 3.2.1 and i don't have any problem. Downgrade react-native-push-notification to 3.1.1, just modify the version on you package.json, delete node_modules/ and run "npm install" or "yarn install".
Hope this works for you
Does work for me, tries to downgrade gradle to 3.1.1 also the package to 3.1.1, nothing worked. It works on iOS though.
All the permissions are set, it should work...
i've solved the issue doing the following:
- Downgrade to 3.1.1
- Run gradle clean
- Delete build folders (./android && ./android/app)
- Run react-native run-android again
Hope this works for you, at least temporally.
It works. Thank you!
Are you getting any messages in your output from Android Studio or xcode?
I was having an issue where the icon would sometimes show in the notifications bar but nothing else. After looking through my logcat I found the below error. Someone, I can't find the link now, mentioned that these are required to work in Android manifest even though the the readme states otherwise...
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="YOUR NOTIFICATION CHANNEL NAME"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
Logcat error:
.../RNPushNotification: failed to send push notification
java.lang.IllegalArgumentException
at android.os.Parcel.readException(Parcel.java:2009)
...
You will not see a notification if the app is in the foreground on iOS. That is expected behavior
For testing in the foreground try this code
PushNotification.localNotificationSchedule({
//... You can use all the options from localNotifications
message: "My Notification Message", // (required)
date: new Date(Date.now() + (60 * 1000)) // in 60 secs
});
@olegdev did the trick for me.
i've solved the issue doing the following:
- Downgrade to 3.1.1
- Run gradle clean
- Delete build folders (./android && ./android/app)
- Run react-native run-android again
Hope this works for you, at least temporally.
Did the trick, thanks!
I was running into this issue as well. For those who can't (or don't want to) delete their./android build folders, check your android manifest.
You might be missing necessary permissions and metadata (listed here in the manual installation page): https://github.com/zo0r/react-native-push-notification#android-manual-installation