sparrowcode / PermissionsKit

Universal API for request permission and get its statuses.
https://x.com/sparrowcode_ios
MIT License
5.64k stars 462 forks source link

[REQ]is There a way to use RequestPermission with OneSignal ? #10

Closed vmacavero closed 7 years ago

vmacavero commented 7 years ago

Hi, i'm currently using OneSignal for my push notifications in my iOS project. To instantiate OneSignal, i have to do `OneSignal.initWithLaunchOptions(....)' in the Application.DidFinishingLaunchingWithOption func of the Application Delegate. This automatically fires the standard request for Push Permissions.

I'd Like to use RequestPermission before all of this happens, but seems i can't because i've to instantiate RequestPermission in a Controller (and none is created at the Application Delegate flow of the app).

Is there a way/workaround ?

Thanks!

Victor

ivanvorobei commented 7 years ago

If I understand correctly, do you want to request permission through RequestPermission, and then initialize OneSignal?

vmacavero commented 7 years ago

exactly ! the problem is the onesignal init happens before i'm able to instantiate RequestPermission.

Thanks.

Victor

ivanvorobei commented 7 years ago

@vmacavero, use EventDelegate. Once the user permits notifications - initialize onesignal

vmacavero commented 7 years ago

ok, Thanks Ivan. I'll Try. 👍

rostopira commented 7 years ago

@vmacavero there is a setting, to disable auto-prompt

OneSignal.initWithLaunchOptions(launchOptions, appId: AppDelegate.OS_APP_ID,
                handleNotificationReceived: {},
                handleNotificationAction: {_ in},
                settings: [kOSSettingsKeyAutoPrompt:false])

Check docs: https://documentation.onesignal.com/docs/ios-native-sdk#section--kossettingskeyautoprompt-