Files
bsky-social-app/modules/expo-bluesky-swiss-army/ios/NotificationSettings/ExpoBlueskyNotificationSettingsModule.swift
T
Claude 38ba6e66c1 Route iOS notification settings intent into the app
Request push notification permissions with provideAppNotificationSettings
so iOS surfaces an in-app notification settings button on the system
Settings screen. Since passing an options object opts out of the default
alert/badge/sound permissions, set those explicitly to preserve behavior.

Handle the resulting openSettingsForNotification callback in a new
NotificationSettings sub-module in expo-bluesky-swiss-army, which registers
a NotificationDelegate with expo-notifications' NotificationCenterManager
and converts the callback into a bluesky://settings/notifications deep link
that the existing linking config routes to the notification settings screen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017BwQMxeGwza3oUcWSBNiKq
2026-06-28 11:10:28 +03:00

41 lines
1.4 KiB
Swift

import EXNotifications
import ExpoModulesCore
import UIKit
import UserNotifications
/*
* When we request push notification permissions with
* `provideAppNotificationSettings: true`, iOS adds an in-app notification
* settings button to the system Settings screen for Bluesky (and may surface
* it elsewhere, e.g. from a delivered notification). Tapping it launches the
* app and calls `userNotificationCenter(_:openSettingsFor:)`.
*
* expo-notifications owns the `UNUserNotificationCenter` delegate via its
* `NotificationCenterManager`, which fans that callback out to any registered
* `NotificationDelegate` through `openSettings(_:)`. We register here and turn
* the callback into a `bluesky://settings/notifications` deep link so the app's
* existing linking config routes the user to the notification settings screen.
*/
public class ExpoBlueskyNotificationSettingsModule: Module, NotificationDelegate {
public func definition() -> ModuleDefinition {
Name("ExpoBlueskyNotificationSettings")
OnCreate {
NotificationCenterManager.shared.addDelegate(self)
}
OnDestroy {
NotificationCenterManager.shared.removeDelegate(self)
}
}
public func openSettings(_ notification: UNNotification?) {
guard let url = URL(string: "bluesky://settings/notifications") else {
return
}
DispatchQueue.main.async {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
}