Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.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
Node.js 如何管理。信息。是否需要为本地化配置AndroidNotification?_Node.js_Firebase_Flutter_Google Cloud Functions_Firebase Cloud Messaging - Fatal编程技术网

Node.js 如何管理。信息。是否需要为本地化配置AndroidNotification?

Node.js 如何管理。信息。是否需要为本地化配置AndroidNotification?,node.js,firebase,flutter,google-cloud-functions,firebase-cloud-messaging,Node.js,Firebase,Flutter,Google Cloud Functions,Firebase Cloud Messaging,在firebase文档中,我发现admin。信息。AndroidNotification具有为通知提供本地化的属性。至少我从中了解到了这一点 在文档中,他们有bodyLocArgs和bodyLocKey来定位body和titleLocKey。为了本地化我的通知,需要如何配置这些 假设我的客户机(android设备)正在使用en_US作为他的当前语言。我的客户端区域设置是否用于本地化通知 这就是我当前的信息 const translator = deviceData.language !== '

在firebase文档中,我发现
admin。信息。AndroidNotification
具有为通知提供本地化的属性。至少我从中了解到了这一点

在文档中,他们有bodyLocArgs和bodyLocKey来定位body和titleLocKey。为了本地化我的通知,需要如何配置这些

假设我的客户机(android设备)正在使用en_US作为他的当前语言。我的客户端区域设置是否用于本地化通知

这就是我当前的信息

const translator = deviceData.language !== 'nl' ? languages.en : languages.nl;
const title = `${translator['messageTitle' as keyof typeof translator]} ${group.displayName}`;
const body =  `${sender.displayName} ${translator[type as keyof typeof translator]}`;

const systemTrayNotification: TokenMessage = {
    token: deviceData.cloudMessagingToken,
    notification: {
        title: title,
        body: body,
    },
    data: {
        title: title,
        body: body,
        senderId: sender.id,
        senderDisplayName: sender.displayName,
        groupId: group.id,
        type: 'groupMessage',
        messageType: type,
        sentAt: new Date().toISOString(),
    },
    android: {
        priority: 'high',
        notification: {
            priority: 'max',
            channelId: '59054',
            clickAction: 'FLUTTER_NOTIFICATION_CLICK',
            tag: 'groupMessage',
            defaultSound: true,
            defaultVibrateTimings: true,
            bodyLocArgs: //what do I do here?,
            bodyLocKey: //what do I do here?
            titleLocArgs: //what do I do here?,
            titleLocKey: //what do I do here?
        }
    },
    apns: {
        payload: {
            aps: {
                category: 'groupMessage',
                headers:{
                    "apns-priority":"10"
                },
                alert: {
                    title: title,
                    body: body,
                },
                aps: {
                    sound: 'default',
                },
                customData: {
                    title: title,
                    body: body,
                    senderId: sender.id,
                    senderDisplayName: sender.displayName,
                    groupId: group.id,
                    type: 'groupMessage',
                    messageType: type,
                    sentAt: new Date().toISOString(),
                }
            }
        },
    }
}
像这样使用

body: jsonEncode({
          'notification': <String, dynamic>{
            'title_loc_key': 'BOOKING_RECEIVED_PUSH_SUBTITLE',
            'title_loc_args': [booking.shopName],
            'body_loc_key': 'BOOKING_RECEIVED_PUSH_BODY',
            'body_loc_args': [
              customerName,
              '',
              bookingStart
            ], //, bookingDate, bookingStart]),
            'sound': 'true',
            'mutable_content': 'true',
            'content_available': 'true'
},
          'priority': 'high',
          'data': <String, dynamic>{
            'click_action': 'FLUTTER_NOTIFICATION_CLICK',
            'id': '1',
            'status': 'done'
          },
          'to': customerFCMToken
        })).whenComplete(() {
      print('sendBookingReceived(): message sent');
    }).catchError((e) {
      print('sendBookingReceived() error: $e');
    });
body:jsonEncode({
“通知”:{
“title_loc_key”:“BOOKING_RECEIVED_PUSH_SUBTITLE”,
“title_loc_args:[booking.shopName],
“body_loc_key”:“BOOKING_RECEIVED_PUSH_body”,
“body_loc_args”:[
客户名称,
'',
预订开始
],/,预订日期,预订开始日期],
‘声音’:‘正确’,
'mutable_content':'true',
“内容可用”:“正确”
},
“优先级”:“高”,
“数据”:{
“点击动作”:“颤振通知点击”,
“id”:“1”,
“状态”:“完成”
},
“to”:customerFCMToken
})).完成时(){
打印('sendBookingReceived():消息已发送');
}).catchError((e){
打印('sendBookingReceived()错误:$e');
});
试试这个,让我知道它是否有效。

像这样使用

body: jsonEncode({
          'notification': <String, dynamic>{
            'title_loc_key': 'BOOKING_RECEIVED_PUSH_SUBTITLE',
            'title_loc_args': [booking.shopName],
            'body_loc_key': 'BOOKING_RECEIVED_PUSH_BODY',
            'body_loc_args': [
              customerName,
              '',
              bookingStart
            ], //, bookingDate, bookingStart]),
            'sound': 'true',
            'mutable_content': 'true',
            'content_available': 'true'
},
          'priority': 'high',
          'data': <String, dynamic>{
            'click_action': 'FLUTTER_NOTIFICATION_CLICK',
            'id': '1',
            'status': 'done'
          },
          'to': customerFCMToken
        })).whenComplete(() {
      print('sendBookingReceived(): message sent');
    }).catchError((e) {
      print('sendBookingReceived() error: $e');
    });
body:jsonEncode({
“通知”:{
“title_loc_key”:“BOOKING_RECEIVED_PUSH_SUBTITLE”,
“title_loc_args:[booking.shopName],
“body_loc_key”:“BOOKING_RECEIVED_PUSH_body”,
“body_loc_args”:[
客户名称,
'',
预订开始
],/,预订日期,预订开始日期],
‘声音’:‘正确’,
'mutable_content':'true',
“内容可用”:“正确”
},
“优先级”:“高”,
“数据”:{
“点击动作”:“颤振通知点击”,
“id”:“1”,
“状态”:“完成”
},
“to”:customerFCMToken
})).完成时(){
打印('sendBookingReceived():消息已发送');
}).catchError((e){
打印('sendBookingReceived()错误:$e');
});
试试这个,让我知道它是否工作。

请也跟着这个。请也跟着这个