Pubnub + React native - iOS 真实设备上没有横幅通知
Pubnub + React native - No banner notification on iOS real device
我已经将 Pubnub Javascript sdk-v4 集成到我的 React Native 项目中。
并使用 https://github.com/zo0r/react-native-push-notification 来响应本机推送通知。在两个模拟器(android 和 iOS)中,当应用程序在后台 运行 时,通知横幅会显示(即使应用程序已关闭)。但是,在真实设备上测试时不会显示通知横幅。通知仅显示在通知栏中(从屏幕顶部滚动时)。有什么建议吗?
代码段如下。
.
.
var PushNotification = require('react-native-push-notification');
var serviceCall = require('../../actions/serviceCall');
import PushController from '../../actions/pushController'
var PubNub = require('pubnub');
.
.
class SearchBar extends Component {
constructor(props) {
super(props);
this.state = {
...
...
};
this.constructor.childContextTypes = {
theme: React.PropTypes.object,
}
}
componentDidMount(){
var pubnub = new PubNub({
publishKey : 'pub-c-xxxxxx',
subscribeKey : 'sub-c-xxxxxx'
})
var notifyListener ={
message: function(message) {
console.warn(JSON.stringify(message));
PushNotification.localNotification({
message: message.message.text, // (required)
});
}
}
pubnub.addListener(notifyListener);
pubnub.subscribe({
channels: ['Channel-xxxxxxx']
});
}
return (
<Container>
<View theme={theme}>
<PushController/>
.
.
.
</View>
</Container>
)
}
我不得不更改集成方法,这 link 成功了。
Link: https://www.pubnub.com/docs/react-native-javascript/mobile-gateway
我已经将 Pubnub Javascript sdk-v4 集成到我的 React Native 项目中。 并使用 https://github.com/zo0r/react-native-push-notification 来响应本机推送通知。在两个模拟器(android 和 iOS)中,当应用程序在后台 运行 时,通知横幅会显示(即使应用程序已关闭)。但是,在真实设备上测试时不会显示通知横幅。通知仅显示在通知栏中(从屏幕顶部滚动时)。有什么建议吗?
代码段如下。
.
.
var PushNotification = require('react-native-push-notification');
var serviceCall = require('../../actions/serviceCall');
import PushController from '../../actions/pushController'
var PubNub = require('pubnub');
.
.
class SearchBar extends Component {
constructor(props) {
super(props);
this.state = {
...
...
};
this.constructor.childContextTypes = {
theme: React.PropTypes.object,
}
}
componentDidMount(){
var pubnub = new PubNub({
publishKey : 'pub-c-xxxxxx',
subscribeKey : 'sub-c-xxxxxx'
})
var notifyListener ={
message: function(message) {
console.warn(JSON.stringify(message));
PushNotification.localNotification({
message: message.message.text, // (required)
});
}
}
pubnub.addListener(notifyListener);
pubnub.subscribe({
channels: ['Channel-xxxxxxx']
});
}
return (
<Container>
<View theme={theme}>
<PushController/>
.
.
.
</View>
</Container>
)
}
我不得不更改集成方法,这 link 成功了。
Link: https://www.pubnub.com/docs/react-native-javascript/mobile-gateway