我使用React Native开发了一个跨平台混合应用程序。
我通过 Amazon SNS集成了远程推送通知。
我尝试了很多插件,但主要是zo0r/react-native-push-notification
通知到达 Android 手机并立即执行“onNotification”回调。(ios手机我还没试过)
没关系,但不是我需要的。
无论应用程序的状态是什么(在前台、后台或关闭),我都想在用户触摸通知时获取点击/触摸事件。
我需要通知的有效负载来打开应用程序中应引导用户访问的合适的 Web 视图。
我尝试处理远程通知并推送新的本地通知,但我没有得到我正在寻找的事件。
android push-notification react-native react-native-push-notification
我正在尝试安装 rn-push-notifications,我需要 google play services 版本和 firebase 版本。你能帮我一下吗?
javascript react-native react-native-push-notification react-notifications
当用户打开应用程序时,我正在寻找react-native-push-notification中的重置应用程序徽章编号,但在文档中的任何位置都找不到该方法,知道吗?
push-notification react-native react-native-push-notification
有人可以让我知道我哪里出错了。从我可以上看到的说明....世界上没有如果你只使用本地通知,并使用autolinking ....除了添加需要到Android特定文件修改googlePlayServicesVersion = "<Your play services version>" // default: "+"到android/build.gradle....,并<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>加<uses-permission android:name="android.permission.VIBRATE" />至AndroidManifest.xml
下面是我的主要源代码
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: function(token) {
console.log('onRegister token:', token);
},
// (required) Called when a remote is received or opened, or local notification is opened
onNotification: function(notification) {
console.log('onNotification:', notification);
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
// Should the initial notification be popped automatically
popInitialNotification: true,
requestPermissions: true,
});
userNowInactive = …Run Code Online (Sandbox Code Playgroud) react-native react-native-android react-native-push-notification
我试图在react-native应用上添加推送通知,所以我使用了react-native-push-notification。库配置运行良好,但是在收到通知时,APP崩溃,并立即提示“ FirebaseApp未初始化”。
崩溃报告 AndroidRuntime:java.lang.IllegalStateException:在此com.myapp中未初始化默认FirebaseApp。确保首先调用FirebaseApp.initializeApp(Context)。
如何初始化FirebaseApp或解决此问题?任何帮助将不胜感激。
有关更多信息,请参见Github问题https://github.com/zo0r/react-native-push-notification/issues/852
android firebase react-native firebase-cloud-messaging react-native-push-notification
当我的应用程序从后台恢复时,我想运行这些代码。为此,我使用 AppState.addEventListener() 注册了一个事件。
const handleAppStateChange = () => {
console.log('Do stuff')
}
constructor(props: Props) {
super(props)
AppState.addEventListener('change', this.handleAppStateChange)
}
componentWillUnmount() {
AppState.removeEventListener('change', this.handleAppStateChange)
}
Run Code Online (Sandbox Code Playgroud)
当我通常退出应用程序并恢复时,它会按预期打印“做事”,但是(这是问题所在),当应用程序最小化并点击通知时,应用程序将打印“做事”两次。
我发现这是因为当我点击通知时,它似乎重新运行了应用程序(包括构造函数部分),这意味着它创建了第二个事件侦听器......
那么,有没有人知道为什么在点击通知时这样做,以及我是否可以阻止它(使用 react-native-push-notification 插件),或者是否有办法确保重复事件未注册?
这发生在我的 Android 物理设备上,不确定它是否也是 iOS 问题,但只是想我会检查是否有人知道这是否可行)
我想在单击远程推送通知后导航到特定的应用程序屏幕。我如何用本机反应来实现这个。我正在使用react-native-push-notification库
push-notification reactjs react-native react-native-push-notification
(在将此问题标记为重复之前,请阅读整个问题)
我在 React-Native 应用程序中使用react-native-push-notification库。
在我的应用中,我还没有初始化 Firebase,因为我现在不需要任何远程通知。目前我正在安排本地通知,当通知到来时,我期待用户的操作。根据按下的按钮,我想进行适当的 API 调用。
因此,为了实现这一点,我使用了 PushNotification.configure 方法,但它向我抛出“在此过程中未初始化默认 FirebaseApp。确保已初始化 Firebase”错误。
当我完全不需要它时,我被迫使用 Firebase。
有人可以在这里帮助我吗,我过去两天一直在寻找答案。我是 React Native 的新手,我仍在学习它。任何帮助表示赞赏。
谢谢
我是移动应用程序开发的新手,我一直在研究推送通知,并且我知道您有本地通知、设备上的静态通知和远程通知,从通知服务器(不是应用程序服务器)发送,我是尝试使用这个库,这是一个非常流行的用于推送通知的库:
https://github.com/zo0r/react-native-push-notification
我可以理解如何在 React Native 项目中设置它并使用本地通知,因为我找到了它的特定教程,但该教程仅展示了如何使用本地通知。
我一直在寻找更多关于如何逐步使用这个库进行远程通知的文档,从设置通知服务器到在React Native应用程序中使用它,但它们都是如此模糊的解释或使用不同的工具。
我正在使用react-native-push-notificationsnpm 库在我的应用程序中实现通知功能。但是,我想安排通知,我正在使用它PushNotification.localNotificationSchedule。但不知何故,当我试图触发时它不起作用。我已经粘贴了下面的代码。有人可以帮我解决这个问题我是这个功能的新手。
事件处理程序
const testPush = () =>{
PushNotification.localNotificationSchedule({
title:'My notification title',
date:new Date(new Date().getTime()+3000),
message:'My notification Message',
allowWhileIdle:false
});
}
Run Code Online (Sandbox Code Playgroud)
事件触发器
<Pressable
onPress={testPush}
style={{ marginTop: 13 }}
>
<View style={{ backgroundColor: '#20232a', padding: 13, alignItems: 'center', borderRadius: 10 }}>
<Text style={{ color: '#ffffff' }}>Test push</Text>
</View>
</Pressable>
Run Code Online (Sandbox Code Playgroud) javascript push-notification npm react-native react-native-push-notification
我正在使用使用自动链接的 react-native 0.62 我想知道是否有一种方法可以自动链接仅适用于 android 或仅适用于 ios。
我真正的问题是我使用 react-native-firebsae 和 react-native-push-notification 来发送本地通知,而我只需要为 android 使用“react-native-push-notification”。
在我添加“react-native-push-notification”并执行 pod install 后,我的 IOS 显示错误“Invarian Violation: Native module cannot be null”。先感谢您
react-native react-native-firebase react-native-push-notification
我一直致力于使用firebase-adminversion^9.2.0和react-native-push-notificationversion添加自定义声音来推送react-native应用程序的通知^5.1.0。
我没有升级到最新版本的原因react-native-push-notification是,即使使用正确的通道配置,自定义声音似乎也不起作用。我们也在使用 expo,它在使用 7+ 版本时似乎会导致启动错误。
我有两个名为regular.mp3和 的mp3 文件mass.mp3。发送推送通知的 firebase 函数使用通用数据对象发送消息,还使用推送通知声音的平台特定字段:
admin.messaging().send({
data: {
title,
body,
lat: data.Latitude.toString(),
lng: data.Longitude.toString(),
notificationType: data.NotificationType.toString(),
},
notification:{title,body},
apns:{
payload:{
aps:{
alert:{
title,
body,
},
sound: data.NotificationType === 1 ? "mass.mp3" : "regular.mp3",
},
},
},
android: {
priority: "high",
data: {
sound: data.NotificationType === 1 ? "mass" : "regular",
},
notification: {
sound: data.NotificationType === 1 ? "mass" : "regular", …Run Code Online (Sandbox Code Playgroud) android push-notification firebase react-native react-native-push-notification
任务“:app:processReleaseMainManifest”执行失败。
清单合并失败:需要为元素 <receiver#com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver> 显式指定android:exported 。
android:exported当相应组件定义了意图过滤器时,面向 Android 12 及更高版本的应用需要指定显式值。
AndroidManifesr.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.projectrn">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- 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 …Run Code Online (Sandbox Code Playgroud) react-native ×13
react-native-push-notification ×13
android ×5
firebase ×2
javascript ×2
reactjs ×2
npm ×1