Skip to content

Commit 6c3587c

Browse files
committed
feat(ios): adding openAppNotificationsSettings function
1 parent db6ec2e commit 6c3587c

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

ios/NotificationsUtils.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
@interface RCT_EXTERN_MODULE(NotificationsUtils, NSObject)
44

5-
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
6-
withResolver:(RCTPromiseResolveBlock)resolve
7-
withRejecter:(RCTPromiseRejectBlock)reject)
5+
RCT_EXTERN_METHOD(openAppNotificationsSettings)
86

97
+ (BOOL)requiresMainQueueSetup
108
{

ios/NotificationsUtils.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1+
import UIKit
2+
13
@objc(NotificationsUtils)
24
class NotificationsUtils: NSObject {
5+
func openURL(_ url: URL) -> Void {
6+
if #available(iOS 10.0, *){
7+
UIApplication.shared.open(url)
8+
} else {
9+
UIApplication.shared.openURL(url)
10+
}
11+
}
12+
13+
@objc(openAppNotificationsSettings)
14+
func openAppNotificationsSettings() -> Void {
15+
let settingsURLString: String;
16+
if #available(iOS 16.0, *) {
17+
settingsURLString = UIApplication.openNotificationSettingsURLString
18+
} else if #available(iOS 15.4, *) {
19+
settingsURLString = UIApplicationOpenNotificationSettingsURLString
20+
} else {
21+
settingsURLString = UIApplication.openSettingsURLString
22+
}
323

4-
@objc(multiply:withB:withResolver:withRejecter:)
5-
func multiply(a: Float, b: Float, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
6-
resolve(a*b)
24+
openURL(URL.init(string: settingsURLString)!)
725
}
826
}

0 commit comments

Comments
 (0)