2017-02-01 3 views
2

私はOneSignal sdkを反応ネイティブに使用します。私はアプリケーションがフォーカスにあるときに内部アラームを無効にしようとします。それをどうやって行うのか考えていますか?ここで ios:アプリケーションがフォーカスしているときに警告通知を無効にする(OneSignal)

は私のコードです:

OneSignal.configure({ 
onIdsAvailable: function (device) { 
    console.log('UserId = ', device.userId); 
console.log('PushToken = ', device.pushToken); 
getUserId(device.userId); 
}, 
onNotificationReceived: function (notification) { 
OneSignal.checkPermissions((permissions) => { 
    console.log(permissions); 
}); 
OneSignal.inFocusDisplaying(0); 
}, 
onNotificationOpened: function(message, data, isActive) { 
console.log("MS TYPE", message); 
switch(message.notification.payload.additionalData.type) { 
case '1': 
     Actions.messenger({id:  message.notification.payload.additionalData.userID}); 
    break; 
case '2': 
     Actions.overview(); 
    break; 
    } 
    } 
}); 

答えて

1

私はあなたが好きcomponentWillMountの上に置く必要があるあなたがOneSignal.inFocusDisplaying(0);

を置く場所をあなたのコードに問題があると思い

componentWillMount() { 
    OneSignal.addEventListener('received', this.onReceived.bind(this)) 
    OneSignal.addEventListener('opened', this.onOpened) 
    OneSignal.addEventListener('registered', this.onRegistered) 
    OneSignal.addEventListener('ids', this.onIds.bind(this)) 

    // Set inFocusDisplaying to prevent the default push notification alert when the is in focus 
    // Android ONLY 
    OneSignal.inFocusDisplaying(0) 
    } 
関連する問題