2017-05-24 57 views

回答

0

的操作按鈕應在POST請求中添加。

{ 
"registration_ids": ["my device id"], 
"data": { 
    "title": "AUX Scrum", 
    "message": "Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.", 
    "actions": [ 
     { "icon": "emailGuests", "title": "EMAIL GUESTS", "callback": "app.emailGuests", "foreground": true}, 
     { "icon": "snooze", "title": "SNOOZE", "callback": "app.snooze", "foreground": false} 
    ] 
    } 
} 

enter image description here

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons

+0

我試過了......仍然沒有工作... 這是我的json: { \t「tokens」:[ 「令牌」], \t 「輪廓」: 「crewapp」, \t 「通知」:{ \t \t 「消息」: 「阿羅哈」, \t \t 「動作」:[ { 「圖標」: 「emailGuests」, 「標題」: 「EMAIL GUESTS」,「callback」:「app.emailGuests」,「foreground」:true}, {「icon」:「snooze」,「title」:「SNOOZE」,「callback」:「app.snooze」, 「foreground」:false} ] \t} \t } 我正在使用cordovaV5 push plugin.Should be a reason? – ggigle

+0

什麼意思是「不工作」?是否收到通知?也許按鈕不顯示?顯示,但回調失敗? –

+0

通知成功收到。但沒有任何按鈕被添加到通知 – ggigle

0

在PushV5的notificationReceived事件中,您可以使用Ionic的警報組件彈出通知,該組件具有可自定義的按鈕。

$rootScope.$on('$cordovaPushV5:notificationReceived', function(event, data){ 
    let alert = alertCtrl.create({ 
     title: data.title, 
     message: data.message, 
     buttons: [ 
     { 
      text: 'Nope', 
      handler: data => { 
      console.log('Nope clicked'); 
      } 
     }, 
     { 
      text: 'OK', 
      handler: data => { 
      console.log('OK clicked'); 
      } 
     } 
    ] 
    }); 

    //popup the alert 
    alert.present(); 
}); 

https://ionicframework.com/docs/components/#alert

+0

這是一個解決方案,如果我有我的應用程序在後臺運行,或者如果它是opened.If我的應用程序停止通知悄無任何button.I've發現但是仍然不能正常工作... – ggigle