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 Notification Options support #154

Closed
jan-koz opened this issue Jan 17, 2023 · 5 comments
Closed

iOS Notification Options support #154

jan-koz opened this issue Jan 17, 2023 · 5 comments

Comments

@jan-koz
Copy link

jan-koz commented Jan 17, 2023

Please add support of iOS Notifications Options to make Airship Flutter package more reliable and highly customisable.

@rlepinski
Copy link
Collaborator

Working on a major SDK update where I will add this with foreground presentation options.

@tomalabaster
Copy link

We're facing a similar need here. In our AppDelegate didFinishLaunchingWithOptions method we set our foreground presentation options as appropriate:

NotificationCenter.default.addObserver(forName: Airship.airshipReadyNotification, object: nil, queue: nil) { notification in
    if #available(iOS 14, *) {
        Airship.push.defaultPresentationOptions = [.badge, .banner, .list, .sound]
        Airship.push.notificationOptions = [.badge, .sound]
    } else {
        Airship.push.defaultPresentationOptions = [.alert, .badge, .sound]
        Airship.push.notificationOptions = [.badge, .sound]
    }
}

but we're not auto initialising the Airship SDK and are instead calling takeOff slightly later on from Flutter.

When we call takeOff from Flutter, the platform method handler then calls AirshipAutopilot.attemptTakeOff() (line 184 of SwiftAirshipPlugin.swift) which in turn calls Airship.push.defaultPresentationOptions = [.alert] (line 30 of AirshipAutopilot.swift).

@rlepinski
Copy link
Collaborator

@tomalabaster You may need to delay setting the options til the next run loop by wrapping what you have in

DispatchQueue.main.async {

}

We have a major plugin rewrite coming that will add support for this and potentially be able to set it per notification all through flutter. This PR is the start of it - #161 we are just wrapping up a major native SDK release then we will focus on getting plugins up to date. I am hoping for a new flutter plugin by the end of this month.

@tomalabaster
Copy link

Thanks @rlepinski will give that a try and keep an eye out 👍

@rlepinski
Copy link
Collaborator

We added support in 7.0.0:
Setting options you want to register for:
Airship.push.iOS.setNotificationOptions([IOSNotificationOption.alert, IOSNotificationOption.badge, ...])

Foreground presentation options:
Airship.push.iOS.setForegroundPresentationOptions([IOSForegroundPresentationOption.list, IOSNotificationOption.banner, ...])

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

No branches or pull requests

3 participants