我使用@ angular / fire库在firebase云消息传递中的angular应用程序中实现了web推送通知。我使用了相同的服务工作者,而不是使用单独的服务工作者进行消息传递。可以接收通知,但是单击通知时,什么也没有发生。
当前消息格式,
<div class="clearfix">
<md-input-container class="block">
<div class="col-xs-5 pad-0">
<label class="md-no-float md-container-ignore">Month</label>
</div>
<div class="col-xs-7 pad-col-7">
<md-select class="md-no-asterisk"
ng-model="vm.Search.Month" name="Month"
ng-change="onContractTypeChange()"
id="Month" required>
<md-option ng-value="dateMonth.Value"
ng-repeat="dateMonth in vm.monthList">
{{dateMonth.Text}}
</md-option>
</md-select>
</div>
</md-input-container>
</div>
尝试添加click_action,但无济于事。当应用程序从以下功能运行时,点击事件就会发生。
{
"notification": {
"title": "Hello World 123",
"body": "This is Message from Admin",
"icon": "/assets/icons/icon-512x512.png",
"click_action":"https://www.google.com"
},
"to" : token
}
我正在阅读收到的来自
的通知public onNotificationClick(): void {
this.swPush.notificationClicks.subscribe((msg) => {
console.log('clicked msg: ', msg);
});
}
点击通知后的结果
public receiveMsg(): void {
this.swPush.messages.subscribe((msg) => {
console.log('received Msg: ', msg);
});
}
操作未按预期进行。收到的味精如下
{
action: "",
notification: {
actions: Array(0),
badge: "",
body: "This is Message from Admin",
data: null,
dir: "auto", …
}