1

在安卓上。当应用程序关闭并单击通知时,应用程序会打开,但通知不会调用所需的功能。为什么?我尝试了很多东西,但没有帮助...

简化代码:

前端设置:

const cloudSettings: CloudSettings = {
'core': {
    'app_id': '61d7358c'
},
'push': {
    'sender_id': '1077211678670',
    'pluginConfig': {
        'ios': {
            'alert': true,
            'badge': false,
            'sound': true,
            'clearBadge': true
        },
        'android': {
            'iconColor': '#1BB6EB',
            'sound': true,
            'clearBadge': true, 
            'clearNotifications': false,
            'forceShow': true 
        }
    }
}};

甚至订阅:

ngOnInit() { this.push.plugin.on('notification', data => this.notificationEvent(data)); }

功能:

notificationEvent(data) { console.log('data', data) }

后端:

axios({
                method: 'post',
                url: 'https://api.ionic.io/push/notifications',
                headers: {
                    'Content-Type': 'application/json',
                    Authorization: `Bearer ${config.integrations.ionic.token}`
                },
                data
            });

数据:

{ profile: 'devit1',
  notification:
    { title: 'new entry',
      message: 'new entry',
      payload:
         { type: 1,
           entryId: 2020,
           id: 4191,
           notId: 4191,
           title: 'newEntry',
           message: 'new entry,  },
      ios:
         { title: 'new entry',
           message: 'new entry',
           content_available: 0,
           sound: 'default' },
      android:
         { title: 'new entry',
           message: 'new entry',
           content_available: 0,
           sound: 'default' } 
  },
  tokens: [ 'fZ4_yY:APA91bFYxyT2gsqYvMPfwFYNJVXBwTFkk73-eohDQ_m-f_wfCiJWtUaIazG39' ] }
4

0 回答 0