Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ios asking notification permission optioanal at start and exposing permissonUtil #27

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

mirzemehdi
Copy link
Owner

Solves this issue: #22

@mirzemehdi mirzemehdi linked an issue Apr 29, 2024 that may be closed by this pull request
@mirzemehdi
Copy link
Owner Author

By default in IOS, notification permission will be asked when application starts. But if you want to handle permission yourself whenever you want, then when initializing library you can pass askNotificationPermissionOnStart value as false in IOS configuration.

Ios initalization

NotifierManager.initialize(
  configuration = NotificationPlatformConfiguration.Ios(
    askNotificationPermissionOnStart = false, //Default value is true
  )
)

@mirzemehdi
Copy link
Owner Author

mirzemehdi commented Apr 29, 2024

Also, PermissionUtil class is exposed in commonMain, that you can use as an utility class for asking permission or checking notification permission for ios. You can get it using

val permissionUtil = NotifierManager.getPermissionUtil()
permissionUtil.askNotificationPermission()

However, In Android this function is just a mock. You need to ask permission in Android activity using like below:

val permissionUtil by permissionUtil()
permissionUtil.askNotificationPermission()

⚠️Warning: PermissionUtil is exposed as an experimental as this library doesn't focus around permissions!. It is there just for making things easier if needed

@mirzemehdi mirzemehdi merged commit 4ecc017 into main Apr 29, 2024
7 checks passed
@mirzemehdi mirzemehdi changed the title Ios asking notification permission optioan at start and exposing permissonUtil Ios asking notification permission optioanal at start and exposing permissonUtil Apr 29, 2024
@mirzemehdi mirzemehdi deleted the ios_notification_permission branch April 29, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request permission optional at init
1 participant