标签: firebase-cloud-messaging

FCM(Firebase云消息传递)发送到多个设备组

从Firebase文档和StackOverflow问题,我了解到我们可以通过主题消息设备组消息将推送通知发送到多个设备.但我想知道是否有办法在单个FCM发送请求中触发推送通知到多个设备组?

基本上,我不想为同一个推送通知消息调用多个请求.我有多个设备组的原因是因为数字成员(即)上有一个上限,而不是一个notification_key.

我不想将消息发布到主题的原因基本上是由于我的要求限制.我的要求是"我在后端生成了一些警报消息,同样只需要向少数用户发送(用户可以登录多个设备),我可以预见的主题是我买不起的问题主题中的动态属性.

如果有办法实现主题,请提出您的建议.

android ios firebase firebase-cloud-messaging

1
推荐指数
2
解决办法
4752
查看次数

如果app在后台,如何使用fcm从服务器发送数据?

我从服务器向我的应用程序发送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)

java android background firebase firebase-cloud-messaging

1
推荐指数
1
解决办法
5876
查看次数

在烧瓶中发送发布请求

我正在尝试在烧瓶中发送发帖请求。

我想发送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'

有关如何解决此问题的任何建议?

python json firebase firebase-cloud-messaging

1
推荐指数
1
解决办法
7450
查看次数

如何将FCM集成到React JS应用程序中?

我想将fcm集成到react js应用程序中以提供实时聊天。有什么投入要进行吗?

firebase reactjs firebase-cloud-messaging

1
推荐指数
1
解决办法
4039
查看次数

Firebase在Xcode 8.3上发布iOS 10.3 Swift 3 FCM通知无效

我正在使用Swift 3iOS 10.3.2开发Xcode 8.3.2,我的项目使用firebase云消息传递,当我的p12证书过期时,我根据建议的Firebase文档更新了我的证书p12p8,但是推送通知停止了,昨天,当我使用控制台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 swift3 firebase-cloud-messaging ios10.3

1
推荐指数
1
解决办法
6088
查看次数

将Firebase Framework添加到iOS未定义的符号

我正在尝试将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

1
推荐指数
1
解决办法
588
查看次数

Firebase云消息传递声音错误

我正在尝试使用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 firebase-cloud-messaging

1
推荐指数
1
解决办法
2479
查看次数

错误:提供给sendToDevice()的注册令牌必须是非空字符串或非空数组

我正在尝试使用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

1
推荐指数
1
解决办法
1744
查看次数

尝试发送消息以测试FCM是否有效但应用程序崩溃

尝试构建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)

android firebase firebase-cloud-messaging

1
推荐指数
1
解决办法
891
查看次数

通知频道错误

我有一个可以接收FCM通知的应用程序。该应用程序在Android Oreo设备以下的操作系统上已收到通知。但是通知未在android oreo设备中接收。它没有发出通知,而是发出了敬酒消息:“开发人员警告程序包无法在通道null上发布通知”。我搜索并了解到通知通道是必需的,但是我不知道要在哪里添加通知通道。请给我指导。吐司正出现在8.0仿真器上。

android android-notifications firebase-cloud-messaging android-8.0-oreo notification-channel

1
推荐指数
1
解决办法
2599
查看次数