代码之家  ›  专栏  ›  技术社区  ›  Rahmat Siswanto

Node JS google cloud messaging topic with prefix got Error:主题名称格式错误[duplicate]

  •  2
  • Rahmat Siswanto  · 技术社区  · 6 年前

    this link

    没有前缀,一切正常,但当我试图添加前缀,我得到“错误:主题名称格式错误”

    app.post('/notify', (request, response) => {
    // console.log(request.body);
    var message = {
        android: {
            ttl: 3600 * 1000, // 1 hour in milliseconds
            priority: 'normal',
            notification: {
                title: request.body.fullname + ' want to join',
                body: 'email: ' + request.body.email + '; tel: ' + request.body.no_telp,
                icon: 'stock_ticker_update',
                color: '#0088aa'
            },
            data: request.body
        },
        topic: '/register/guest'
    };
    
    admin.messaging().send(message)
    .then((res) => {
        // Response is a message ID string.
        console.log('Successfully sent message:', res);
        response.send("success");
    })
    .catch((error) => {
        console.log('Error sending message:', error);
        response.send('error');
    });
    

    })

    1 回复  |  直到 6 年前
        1
  •  0
  •   Veikko    6 年前

    在我看来,第页示例代码的第一行中的注释 https://firebase.google.com/docs/cloud-messaging/admin/send-messages 不正确。在“定义信息”下明确指出

    推荐文章