我从服务器向我的应用程序发送fcm通知.
我从服务器发送包含user_id的数据.如果应用程序位于前台,我将在FirebaseMessageService类中获取此userId.但是,当应用程序处于后台时,不会得到它.由于FirebaseMessagingService类仅在应用程序位于前台时才会执行.
那么当应用程序处于后台时,如何获得此ID?
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
private String mUserId;
private Boolean mUpdateNotification;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//Displaying data in log
//It is optional
Log.d(TAG, "From: " + remoteMessage.getFrom());
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
String clickAction = remoteMessage.getNotification().getClickAction();
mUserId = remoteMessage.getData().get("user_id");
String title = remoteMessage.getNotification().getTitle();
//Calling method to generate notification
sendNotification(remoteMessage.getNotification().getBody(),clickAction,title);
}
//This method is only generating push notification
//It is same as we did in earlier …Run Code Online (Sandbox Code Playgroud) 我正在尝试在烧瓶中发送发帖请求。
我想发送Content-Type: application/json设置为标头的json对象。
我正在使用请求模块执行以下操作:
json_fcm_data = {"data":[{'key':app.config['FCM_APP_TOKEN']}], "notification":[{'title':'Wyslalem cos z serwera', 'body':'Me'}], "to":User.query.filter_by(id=2).first().fcm_token}
json_string = json.dumps(json_fcm_data)
print json_string
res = requests.post('https://fcm.googleapis.com/fcm/send', json=json_string)
Run Code Online (Sandbox Code Playgroud)
但这给了我:
TypeError:request()得到了意外的关键字参数'json'
有关如何解决此问题的任何建议?
我想将fcm集成到react js应用程序中以提供实时聊天。有什么投入要进行吗?
我正在使用Swift 3为iOS 10.3.2开发Xcode 8.3.2,我的项目使用firebase云消息传递,当我的p12证书过期时,我根据建议的Firebase文档更新了我的证书p12到p8,但是推送通知停止了,昨天,当我使用控制台firebase进行测试时,它正常工作,但今天没有,日志打印我正常:
2017-05-30 10:13:23.932066-0400 lol[5576:1530669] WARNING: Firebase Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h.
2017-05-30 10:13:23.949512-0400 lol[5576:1530669] Firebase automatic screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO in the Info.plist
2017-05-30 10:13:24.368364-0400 lol[5576:1530669] [Crashlytics] …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Firebase Messaging添加到我的iOS项目中.我无法使用Pod,因为我的Developermachine会破坏它们.所以我手动添加框架.正如自述文件所述,我将分析和消息文件夹的所有框架以及Firebase.h添加到我的Xcode项目中.我添加了其他Stackoverflow问题中提到的Storekit.framework,libz,libc ++和libsqlite3.0,以消除大多数链接器错误.但由于以下错误,我仍然无法编译/链接我的项目:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_SKPaymentQueue", referenced from:
objc-class-ref in FirebaseAnalytics(FIRAInAppPurchaseTransactionReporter_ca1fe3eb82b823d5f96d3f8b4baedc9c.o)
"_OBJC_CLASS_$_SKProductsRequest", referenced from:
objc-class-ref in FirebaseAnalytics(FIRAProductsRequest_8f770071350872416d311668917f3a41.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
我不明白为什么他们会丢失或者我需要添加哪个库来进行此操作.有人知道该怎么办吗?
我还应该提到我在这个项目上使用Qt.
提前致谢,
objective-c linker-errors ios firebase firebase-cloud-messaging
我正在尝试使用firebase api发送通知,如果我在通知JSON对象中只有"title"和"body",则通知会成功发送.但是,如果我向通知对象添加"声音":"默认",如文档中所述,我收到以下错误:
"收到无效的JSON有效负载.未知名称\"声音\"在'message.notification':找不到字段."
我的JSON对象如下:
{"message":{"token": token, "notification":{"title":"Test", "body":"Test message from server", "sound":"default"}}}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Firebase云功能将通知发送到点半径范围内的设备。我可以获取圈子中设备的ID,但无法获取令牌,如使用console.log(token)打印,令牌为null。
const getdevicetokenpromise = db.ref('/DriversAvailable/{key}/token').once('value');
console.log(key); //this value is right
return getdevicetokenpromise.then(result => {
console.log(result.val()); //this value is null, this is the problem
var token = result.val();
const payload = {
notification: {
title: 'title',
body: 'hey, well done dude',
icon: 'default'
}
};
return admin.messaging().sendToDevice(token, payload)
.then((response)=> {
return console.log("Successfully sent message:", response);
})
.catch((error) =>{
console.log("Error sending message:", error);
});
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试了关于stackoverflow的大多数建议,但找不到解决方案。谢谢。
javascript firebase google-cloud-functions firebase-cloud-messaging
尝试构建Firebase聊天应用,并想测试FCM是否有效.尝试通过从firebase控制台发送云消息来测试通知功能,但应用程序在所有设备中崩溃.
这是logcat的错误
06-30 16:11:07.783 26794-26794/com.example.ryzeng.firebasechat E/AndroidRuntime:FATAL EXCEPTION:main进程:com.example.ryzeng.firebasechat,PID:26794 java.lang.NoSuchMethodError:无静态方法zzad ()LCOM /谷歌/火力/ IID/zzan; 在课堂Lcom/google/firebase/iid/zzan; 或com.google.firebase.messaging.FirebaseMessagingService上的超级类('com.google.firebase.iid.zzan'的声明出现在/data/app/com.example.ryzeng.firebasechat-2/split_lib_dependencies_apk.apk中). zzb(未知来源)位于android.app.ActivityThread.-wrap21(ActivityThread.java)的android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3366)的com.google.firebase.iid.zzb.onStartCommand(未知来源)在android.app.A.运行时android.O.上运行android.os.Handler.dispatchMessage(Handler.java:102)的android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1612). app.ActivityThread.main(ActivityThread.java:6236)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:891)at com的java.lang.reflect.Method.invoke(Native Method). android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
我有一个可以接收FCM通知的应用程序。该应用程序在Android Oreo设备以下的操作系统上已收到通知。但是通知未在android oreo设备中接收。它没有发出通知,而是发出了敬酒消息:“开发人员警告程序包无法在通道null上发布通知”。我搜索并了解到通知通道是必需的,但是我不知道要在哪里添加通知通道。请给我指导。吐司正出现在8.0仿真器上。
android android-notifications firebase-cloud-messaging android-8.0-oreo notification-channel
firebase ×9
android ×4
ios ×2
background ×1
ios10.3 ×1
java ×1
javascript ×1
json ×1
objective-c ×1
python ×1
reactjs ×1
swift3 ×1