我正在尝试使用React Native在Android上创建本地通知。我的应用程序完全是本地的,因此我不想使用GCM或FCM。我看到了这个问题,其中使用Java实现了这一点。是否有React Native中的包装器或库来实现相同的功能?
我还看到了PushNotificationIOS
API,它能在Android上工作吗?
我正在尝试使用React Native在Android上创建本地通知。我的应用程序完全是本地的,因此我不想使用GCM或FCM。我看到了这个问题,其中使用Java实现了这一点。是否有React Native中的包装器或库来实现相同的功能?
我还看到了PushNotificationIOS
API,它能在Android上工作吗?
是的,react-native-push-notifications。它在iOS和Android上也支持本地通知。
Wix有最好的通知插件。
包括本地通知和推送(安卓和iOS)Push。
https://github.com/wix/react-native-notifications
如果不想使用推送,可以跳过配置,直接安装和链接即可使用。
npm install --save react-native-notifications
react-native link react-native-notifications
请查看安装指南:https://github.com/wix/react-native-notifications/blob/master/docs/installation.md
使用示例:
let localNotification = NotificationsIOS.localNotification({
body: "Local notificiation!",
title: "Local Notification Title",
sound: "chime.aiff",
silent: false,
category: "SOME_CATEGORY",
userInfo: { }
});
NotificationsAndroid.localNotification({
title: "Local notification",
body: "This notification was generated by the app!",
extra: "data"
});
您可以在https://wix.github.io/react-native-notifications/docs/localNotifications上找到有关本地通知的更多信息。
此外,在Android上可以完全自定义通知布局。