【发布时间】:2019-12-26 00:16:51
【问题描述】:
我将 FCM 插件与 Firebase 云消息传递一起使用。通过对使用设备令牌发送通知的 Cloud Function 进行 http 调用来发送通知。
云函数如下所示:
let payload = {
notification: {
title: 'Pedido completado',
body: 'Gracias por usar nuestro servicio!',
sound: 'boop.mp3',
priority: "high",
icon: 'https://res.cloudinary.com/....Moviapp_icono_512x512.png'
}
};
admin.messaging().sendToDevice([token], payload);
我的 component.ts 是这样的
async getToken(uid) {
const token = await this.fcm.getToken();
const body = { token, usuario: uid };
this.sentTokenToTheServer(body);
}
async sendPushNotification(token) {
const pushURL = `https://us...cloudfunctions.net/pushNotification?token=${token}`;
this.http.get(pushURL, { responseType: 'text' }).toPromise();
}
即使使用自定义图标,通知也能正常工作,但问题是默认情况下仍然存在声音
【问题讨论】:
标签: android firebase ionic3 ionic4