Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Nativescript | Firebase通知不工作_Ios_Node.js_Firebase_Firebase Cloud Messaging_Nativescript - Fatal编程技术网

Ios Nativescript | Firebase通知不工作

Ios Nativescript | Firebase通知不工作,ios,node.js,firebase,firebase-cloud-messaging,nativescript,Ios,Node.js,Firebase,Firebase Cloud Messaging,Nativescript,我在我的Nativescript应用程序中使用firebase时遇到问题,当我使用android时,它工作得很好,但与IOS不兼容。问题出在消息发送上。 我正在客户端使用推送插件 这是使用pushPlugin在IOS客户端的注册部分 const iosSettings:any = { badge: true, sound: true, alert: true, interactiveSettings: { a

我在我的Nativescript应用程序中使用firebase时遇到问题,当我使用android时,它工作得很好,但与IOS不兼容。问题出在消息发送上。 我正在客户端使用推送插件

这是使用pushPlugin在IOS客户端的注册部分

const iosSettings:any = {
        badge: true,
        sound: true,
        alert: true,
        interactiveSettings: {
            actions: [{
                identifier: 'READ_IDENTIFIER',
                title: 'Read',
                activationMode: "foreground",
                destructive: false,
                authenticationRequired: true
            }, {
                identifier: 'CANCEL_IDENTIFIER',
                title: 'Cancel',
                activationMode: "foreground",
                destructive: true,
                authenticationRequired: true
            }],
            categories: [{
                identifier: 'READ_CATEGORY',
                actionsForDefaultContext: ['READ_IDENTIFIER', 'CANCEL_IDENTIFIER'],
                actionsForMinimalContext: ['READ_IDENTIFIER', 'CANCEL_IDENTIFIER']
            }]
        },
        notificationCallbackIOS: (message: any) => {
            alert(JSON.stringify(message));
        }
    };


    pushPlugin.register(iosSettings, (token: string) => {
        // update the token in the server
        alert("Device registered. Access token: " + token);
            });
        }
    }, (errorMessage: any) => {
        alert("Device NOT registered! " + JSON.stringify(errorMessage));
    });
这是我接收推送通知令牌的方式, 当我使用pusher应用程序时,在获得令牌后,一切都很好,我在IOS设备中收到通知 但问题是当我试图从服务器发送通知时

我得到这个错误:

提供的注册令牌无效。确保它与 客户端应用程序通过向FCM注册收到的注册令牌

我的服务器中的节点代码

        var payload = {
        data: {
          targetId:userToken,
          body: "some text"
        }
      };
    var options = {
        priority: "high",
        contentAvailable: true,
        timeToLive: 60 * 60 * 24
      };
    Admin.messaging().sendToDevice(userToken, <any>payload,options)
        .then((response) => {
            console.log('notification arrived successfully', response.results[0]);
        })
        .catch((error) => {
            console.log('notification failed', error);
        });
var有效载荷={
数据:{
targetId:userToken,
正文:“一些文本”
}
};
变量选项={
优先级:“高”,
contentAvailable:true,
寿命:60*60*24
};
Admin.messaging().sendToDevice(用户令牌、有效负载、选项)
。然后((响应)=>{
console.log('通知成功到达',response.results[0]);
})
.catch((错误)=>{
console.log('通知失败',错误);
});

ios的注册令牌与android不同。我遇到了你遇到的同一堵墙。您需要使用
https://github.com/node-apn/node-apn
用于IOS推送通知。和
firebase
用于android通知。您可以通过保存令牌在后端执行逻辑。如果您使用的是ios
node apn
,如果android使用firebase提供的
sendToDevice
,则使用名为
type
的字段,即
ios或android

这就是我目前正在处理的涉及推送通知的nativescript项目所使用的。希望对你有帮助,伙计