我有两个不同的通知。
一个是消息,另一个是其他内容的通知。
我想将通知分开。
例如,当我收到通知消息并点击它时,它会打开聊天室,而另一个则打开另一个活动。
android firebase firebase-cloud-messaging firebase-notifications
我设置了 firebase 云消息传递,在我的onResume()回调中,我有以下内容:
Future<void> onResume(Map<String, dynamic> message) async {
final Map<String,dynamic> data = message['data'];
final String url = data['url'];
if (url != null) {
_webViewController?.loadUrl(url);
}
}
Run Code Online (Sandbox Code Playgroud)
当函数到达时,
final Map<String,dynamic> data = message['data'];
它会过早地、静默地返回,没有警告。
如果我改为运行
final dynamic data = message['data'];
它会按预期继续。
检查message类型狂欢即message是InternalLinkedHashMap,不能太投Map<String, dynamic>。
它说_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'。
我该怎么做呢?
如果这个问题没有踪迹,我以后如何才能找到它?
我正在使用 Firebase 云消息在包含聊天页面的应用程序上推送通知。
我在 main.dart 上定义了我的 firebase 推送函数,如下所示:
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
//_showItemDialog(message);
},
onBackgroundMessage: myBackgroundMessageHandler,
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
//_navigateToItemDetail(message);
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
//_navigateToItemDetail(message);
},
);
Run Code Online (Sandbox Code Playgroud)
当聊天小部件打开并且我收到推送通知时,我的 OnMessage 方法正常到达。
问题是:考虑到打开的页面与声明到达的 OnMessage 函数的页面不同,刷新我的聊天页面的最佳方法是什么?
我正在使用 FCM 进行推送通知。我曾经使用以下方法刷新应用程序的内容
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Run Code Online (Sandbox Code Playgroud)
现在在 iOS13 中,此方法不再触发。我也包括了 apns-push-type 和 apns-priority。
如何在点击通知时转到特定屏幕?我在javascript中使用了云功能,当我点击通知时,它打开了我的应用程序而不是特定的屏幕
_fcm.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
getOrder(message['data']['order_id']);
showDialog(
context: context,
builder: (context) => AlertDialog(
content: ListTile(
title: Text(message['notification']['title']),
subtitle: Text(message['notification']['body']),
),
actions: <Widget>[
FlatButton(
child: Text('Ok'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
},
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailOrder()));
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailOrder()));
},
);
Run Code Online (Sandbox Code Playgroud) push-notification flutter google-cloud-functions firebase-cloud-messaging
我在 reactjs Web 应用程序中使用 fcm 进行推送通知。如果 Web 应用程序在后台运行,我能够收到通知。但是当我的应用程序在前台积极运行时无法收到通知。
Firebase 初始化在我的项目中完美完成,因为我在后台成功收到推送通知。
firebase-messaging-sw.js
importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js');
firebase.initializeApp({
'messagingSenderId': '337889493107'
});
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function (payload) {
const data = JSON.parse(payload.data.notification);
const notificationTitle = data.title;
const notificationOptions = {
body: data.body,
icon: '/favicon.png'
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
messaging.onMessage(function(payload) {
const data = JSON.parse(payload.data.notification);
const notificationTitle = data.title;
const notificationOptions = {
body: data.body,
icon: '/favicon.png'
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
Run Code Online (Sandbox Code Playgroud)
我需要对我的前台方法做任何进一步的修改messaging.onMessage还是需要做更多的配置。请帮帮我
在我的应用程序中,对于网络版本,我使用 package firebase 7.3.0。我首先使用单例实例化 Firebase 应用程序,然后实例化 Messaging(),就像我在我的应用程序中使用的所有其他 Firebase 服务所做的那样:
App firebase = FirebaseWeb.instance.app;
var firebaseMessaging = messaging();
Run Code Online (Sandbox Code Playgroud)
我有subscribeToTopic()方法首先调用getMessagingToken()方法,因为它需要返回的令牌,但getMessagingToken()抛出错误:
PlatformPushNotificationWeb.getMessagingToken() getToken error: FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:5000/firebase-cloud-messaging-push-scope') with script ('http://localhost:5000/firebase-messaging-sw.js'): A bad HTTP response code (404) was received when fetching the script. (messaging/failed-service-worker-registration). (messaging/failed-service-worker-registration)
Run Code Online (Sandbox Code Playgroud)
Future<String> getMessagingToken() async {
String token;
await firebaseMessaging.requestPermission().timeout(Duration(seconds: 5)).then((value) {
print('PlatformPushNotificationWeb.getMessagingToken() requestPermission result is $value');
}).catchError((e) …Run Code Online (Sandbox Code Playgroud) 我尝试过 Firebase 推送通知,但它不起作用。远程消息显示在带有负载的控制台上,但未在模拟器上显示通知。我使用 Xcode 11.5 和 iOS 13。
objective-c apple-push-notifications ios firebase firebase-cloud-messaging
我目前正在调试 FCM 推送消息偶尔无法传送到我的 Android 应用程序的问题。主要设置和配置有效,大多数(高优先级)推送消息都会及时传递 - 但有时并非如此。
在仔细阅读官方故障排除指南 ( https://firebase.google.com/support/troubleshooter/fcm/delivery/diagnose/android ) 时,它建议我拨打电话*#*#426#*#*以获得一些诊断信息。
我现在已经在三部手机(三星 Galaxy S7、三星 XCover 4S、摩托罗拉 Moto X)上尝试过这个,但没有任何反应——手机只是试图打电话。
我假设“拨打此代码”的意思是“打开拨号应用程序,输入此代码,然后接听”。那不正确吗?
我正在使用数据通知来更新我的应用程序状态,它在 Android 上运行良好,但我无法在 IOS 上接收任何数据消息,甚至没有触发 onMessage 侦听器。
我正在使用这些:
firebase_core:^0.7.0
firebase_auth:^0.20.1
firebase_messaging:^8.0.0-dev.15
firebase_analytics:^7.0.0
我正在使用 POSTMAN 来测试它,它在 Android 上运行没有问题,但只是没有收到发送到 IOS 的数据消息。
带有通知字段的通知在前台、后台和终止时完美运行,问题仅在于仅数据消息。
任何帮助表示赞赏。
任何帮助表示赞赏。
firebase ×5
flutter ×4
android ×2
ios ×2
casting ×1
chat ×1
dart ×1
flutter-web ×1
ios13 ×1
javascript ×1
objective-c ×1
reactjs ×1
swift ×1