iphone - Pubnub + React Native - iOS 真实设备上没有横幅通知

标签 iphone react-native push-notification pubnub react-native-ios

我已将 Pubnub Javascript sdk-v4 与我的 React Native 项目集成。 并已使用https://github.com/zo0r/react-native-push-notification用于 react native 推送通知。在两个模拟器(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>
        )
}

最佳答案

我必须更改集成方法,此链接成功。

链接:https://www.pubnub.com/docs/react-native-javascript/mobile-gateway

关于iphone - Pubnub + React Native - iOS 真实设备上没有横幅通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43086932/

相关文章:

iphone - 使用 AUGraph 播放麦克风的声音

react-native - 键盘监听器运行不止一次

ios - react-native:推送通知+解析

react-native - 使用内容组件进度 react 抽屉导航

xamarin - Pushy.Register 上抛出的 PushyNetworkException

ios - 我可以使用哪些 iPhone OS API 来实现类似于 iBook 翻页过渡的过渡动画?

iphone - 如何在 xcode for iphone 中录制后保存音频文件

ios - 如何使用 Swift 获取推送通知状态?

iphone - 如何从 iPhone 应用程序访问和打开 iPhone 的 SMS API

ios - 如何在设定的时间获得推送通知? ( swift 3)