2017-08-28 89 views
1

我使用react-native-push-notification,但是我遇到了問題。
With IOS simulator or android emulator,Everything Everything well。
但與real iphone device,推送通知不起作用。 (在釋放模式或調試模式,兩者都沒有奏效。react-native-push-notification在ios DEVICE上不起作用

這裏是我的設置。

Link binary with Libraries

Set Search Header Path

我檢查Capabilities/Background Modes/Remote notification上XCODE

和PushNotification.configure

import React from 'react'; 
import PushNotification from 'react-native-push-notification'; 

import { 
    Auth 
} from '../config/router'; 
import './ReactotronConfig'; 

export default class App extends React.Component { 
    constructor(props) { 
     super(props); 

     this.PushConfigure(); 
    } 
    PushConfigure() { 
     PushNotification.configure({ 
      onNotification: (notification) => { 
       console.log('NOTIFICATION:', JSON.stringify(notification)); 
      }, 
      permissions: { 
       alert: true, 
       badge: true, 
       sound: true, 
      }, 
      popInitialNotification: true, 
      requestPermissions: true, 
     }); 
    } 
    render() { 
     return <Auth />; 
    } 
} 

當我要推通知

const date = new Date(Date.now()); 
    PushNotification.localNotificationSchedule({ 
     title: '메세지가 도착 했습니다.', 
     message: `${data.user._id}: ${data.text}`, 
     date, 
     actions: 'Yes', 
    }); 

正如我之前所說,通知上順暢運行的所有simulator(Xcode的IOS,Android的)。
但我不知道爲什麼通知不起作用real IOS device

如果你想要更多的環境或設置在我的項目,請評論。

更新 -

我沒有對Apple Developer Program註冊。
這就是爲什麼我不能在真實IOS設備上使用通知的原因嗎?

+0

沒有應用要求對真正的第一次運行通知權限設備? –

+0

請檢查應用程序詢問通知許可,並檢查推送通知的證書是否完美 –

+0

@DithithMinura yes。彈出權限彈出。 –

回答

0

是的,我認爲推送通知不適用於iOS模擬器,因此您需要在真實的設備中檢查此設備,並在製作發佈版本時檢查推送通知的證書是否正確。

也請檢查你的onRegister功能適當的設備令牌

PushNotification.configure({ 
      onRegister: function (token) { 
       console.log((token); 
      }, 
      onNotification: (notification) => { 
       console.log('NOTIFICATION:', JSON.stringify(notification)); 
      }, 
      permissions: { 
       alert: true, 
       badge: true, 
       sound: true, 
      }, 
      popInitialNotification: true, 
      requestPermissions: true, 
     }); 

普萊舍確保在設置推送通知你的應用程序啓用

+0

有什麼辦法可以在本地彈出通知,而無需連接任何服務器,如firebase,APN ..? –

+0

是的,有一種方法,請點擊鏈接。這將幫助你本地通知https://github.com/zo0r/react-native-push-notification和https://medium.com/differential/how-to-setup-push-notifications-in-react-native -ios-android-30ea0131355e –

+0

我首先關注了他們,但通知在真實的IOS設備上不起作用。 –

相關問題