我在通知面板中打开我的react-native应用程序时遇到问题。收到从Web服务器(后端)发送的推送通知时,从通知托盘中点击通知不会打开应用程序。同样,onNotificationOpened方法没有被调用。 同时,当从Firebase控制台推送通知时,它会在点击时打开应用程序。还调用了onNotificationOpened。是否有一些代码可用于通过通知Tap ..打开应用程序???
我尝试在App.js中添加onNotificationOpened侦听器,该侦听器仅适用于从Firebase控制台发送的通知。
从控制台收到的通知json
{ _body: 'Good After noon',
_data: {},
_notificationId: '0:15474xxxxxxxxxx',
_sound: undefined,
_subtitle: undefined,
_title: 'Good After noon',
_android:
{ _notification: [Circular],
_actions: [],
_autoCancel: undefined,
_badgeIconType: undefined,
_bigPicture: undefined,
_bigText: undefined,
_category: undefined,
_channelId: undefined,
_clickAction: undefined,
_color: undefined,
_colorized: undefined,
_contentInfo: undefined,
_defaults: undefined,
_group: 'campaign_collapse_key_1764xxxxxx',
_groupAlertBehaviour: undefined,
_groupSummary: undefined,
_largeIcon: undefined,
_lights: undefined,
_localOnly: undefined,
_number: undefined,
_ongoing: undefined,
_onlyAlertOnce: undefined,
_people: [],
_priority: undefined,
_progress: undefined,
_remoteInputHistory: undefined,
_shortcutId: undefined,
_showWhen: undefined,
_smallIcon: { icon: 'ic_launcher' },
_sortKey: undefined,
_tag: 'campaign_collapse_key_1764xxxxx',
_ticker: undefined,
_timeoutAfter: undefined,
_usesChronometer: undefined,
_vibrate: undefined,
_visibility: undefined,
_when: undefined },
_ios: { _notification: [Circular], _attachments: [] } }
从服务器发送的通知json
{ _body: 'A new booking has been scheduled on 14-01-2019 5:00PM to 6:00PM',
_data: { a_data: '{"type":"Booking","subtype":"create","id":{"id":"5c3cxxxx"}}' },
_notificationId: '0:15474xxxx',
_sound: 'default',
_subtitle: undefined,
_title: 'Booking',
_android:
{ _notification: [Circular],
_actions: [],
_autoCancel: undefined,
_badgeIconType: undefined,
_bigPicture: undefined,
_bigText: undefined,
_category: undefined,
_channelId: undefined,
_clickAction: 'android.intent.action.MAIN',
_color: undefined,
_colorized: undefined,
_contentInfo: undefined,
_defaults: undefined,
_group: undefined,
_groupAlertBehaviour: undefined,
_groupSummary: undefined,
_largeIcon: undefined,
_lights: undefined,
_localOnly: undefined,
_number: undefined,
_ongoing: undefined,
_onlyAlertOnce: undefined,
_people: [],
_priority: undefined,
_progress: undefined,
_remoteInputHistory: undefined,
_shortcutId: undefined,
_showWhen: undefined,
_smallIcon: { icon: 'ic_launcher' },
_sortKey: undefined,
_tag: undefined,
_ticker: undefined,
_timeoutAfter: undefined,
_usesChronometer: undefined,
_vibrate: undefined,
_visibility: undefined,
_when: undefined },
_ios: { _notification: [Circular], _attachments: [] } }