This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PushNotificationIOS from '@react-native-community/push-notification-ios' | |
const showNotifications = (title, message) => { | |
PushNotificationIOS.presentLocalNotification({ | |
alertTitle: title, | |
alertBody: message, | |
}); | |
}; | |
const handleScheduleNotifications = (title, message) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PushNotification from 'react-native-push-notification' | |
const showNotifications = (title, message) => { | |
PushNotification.localNotification({ | |
title: title, | |
message: message, | |
}); | |
}; | |
const handleScheduleNotifications = (title, message) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {View, Text, StyleSheet, TouchableOpacity} from 'react-native'; | |
const App = () => { | |
return( | |
<View style={styles.container}> | |
<Text>Push Notifications</Text> | |
<TouchableOpacity activeOpacity={0.6}> | |
<View style={styles.button}> | |
<Text style={styles.buttonTitle}>Click me to get notification</Text> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
bracketSpacing: true, | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @format | |
*/ | |
import {AppRegistry} from 'react-native'; | |
import App from './App'; | |
import {name as appName} from './app.json'; | |
import PushNotification from 'react-native-push-notification'; | |
import { Platform } from 'react-native'; | |
AppRegistry.registerComponent(appName, () => App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Called when a notification is delivered to a foreground app. | |
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler | |
{ | |
completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Define UNUserNotificationCenter | |
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; | |
center.delegate = self; | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Required for the register event. | |
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken | |
{ | |
[RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; | |
} | |
// Required for the notification event. You must call the completion handler after handling the remote notification. | |
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo | |
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<color name="white">#FFF</color> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) --> | |
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground" | |
android:value="false"/> | |
<!-- Change the resource name to your App's accent color - or any other color you want --> | |
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color" | |
android:resource="@color/white"/> | |
<!-- or @android:color/{name} to use a standard color --> | |
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" /> | |
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> |