React-native-onesignal: OneSignal.inFocusDisplaying(0) not working in iOs

Created on 23 Jan 2017  ·  5Comments  ·  Source: OneSignal/react-native-onesignal

OneSignal.inFocusDisplaying(0)
OneSignal.configure({...

gives me on android, displayType: 0, and does not show the notification

But with iOS, it gives me, displayType: 1, it does show the notification when the app is isAppInFocus

Most helpful comment

in your AppDelegate.m you can put the settings dictionary (optional) and change some default OneSignal settings:

  self.oneSignal = [[RCTOneSignal alloc] initWithLaunchOptions:launchOptions
                     appId:@"YOUR APP ID"
                     settings:@{kOSSettingsKeyInFocusDisplayOption : @(OSNotificationDisplayTypeNone), kOSSettingsKeyAutoPrompt : @YES}];

Sorry for the undocumented part in the module, you can find it here, in the official SDK docs:
https://documentation.onesignal.com/docs/ios-native-sdk#section--kossettingskeyinfocusdisplayoption-

All 5 comments

I just read the doc again I saw: We exposed the inFocusDisplaying API of OneSignal (Android only).

How can I not display the notification on iOS when the app is in Focus ?

in your AppDelegate.m you can put the settings dictionary (optional) and change some default OneSignal settings:

  self.oneSignal = [[RCTOneSignal alloc] initWithLaunchOptions:launchOptions
                     appId:@"YOUR APP ID"
                     settings:@{kOSSettingsKeyInFocusDisplayOption : @(OSNotificationDisplayTypeNone), kOSSettingsKeyAutoPrompt : @YES}];

Sorry for the undocumented part in the module, you can find it here, in the official SDK docs:
https://documentation.onesignal.com/docs/ios-native-sdk#section--kossettingskeyinfocusdisplayoption-

@jsappme @avishayil Hi, if i want to silent the notification on one particular app screen only not whole app, how do i do it?

this now works on the latest SDK

@avishayil I'm getting "Property 'oneSignal' not found on object of type 'AppDelegate *'", with that code, how would I properly define that property for app delegate and do I need to pass the property to onesignal back somehow?

Was this page helpful?
0 / 5 - 0 ratings