我已按照与iOS集成所需的所有步骤进行操作,目前这是我在index.ios.js上的代码
import React, {Component} from 'react'
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native'
import wrapper from './wrapper'
import OneSignal from 'react-native-onesignal'
let pendingNotifications = [];
function handleNotification (notification) { // If you want to handle the notifiaction with a payload.
// _navigator.to('main.post', notification.data.title, {
// article: {
// title: notification.data.title,
// link: notification.data.url,
// action: notification.data.actionSelected
// }
//});
console.log("handle notification data:", notification)
}
OneSignal.configure({
onIdsAvailable: function(device) {
console.log('UserId = ', device.userId);
console.log('PushToken = ', device.pushToken);
},
onNotificationOpened: function(message, data, isActive) {
var notification = {message: message, data: data, isActive: isActive};
console.log('NOTIFICATION OPENED: ', notification);
//if (!_navigator) { // Check if there is a navigator object. If not, waiting with the notification.
// console.log('Navigator is null, adding notification to pending list...');
pendingNotifications.push(notification);
// return;
// }
handleNotification(notification);
}
});
AppRegistry.registerComponent('pvj', () => wrapper)
实际上,当从信号仪表板发送消息时,xcode日志上会触发所有console.log消息,但不是通知......
2016-08-27 23:41:38.536 [info] [tid:com.facebook.react.JavaScript]' NOTIFICATION OPENED:',{message:' Mungkin harus di link ke Push Notificationnya si react-native kali ya', 数据:{声音:'默认',标题:' Ah Gila Ini Susah Banget' }, isActive:true}
2016-08-27 23:41:38.537 [info] [tid:com.facebook.react.JavaScript]'处理通知数据:',{message:' Mungkin harus di link ke Push Notificationnya si react-native kali ya', 数据:{声音:'默认',标题:' Ah Gila Ini Susah Banget' }, isActive:true}
此插件是否需要与PushNotificationIOS进一步集成?
谢谢