Skip to content

Commit 4bfb038

Browse files
committed
refine API for Swift
Refine some more APIs for Swift
1 parent 02cfc96 commit 4bfb038

File tree

6 files changed

+82
-26
lines changed

6 files changed

+82
-26
lines changed

iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ typedef void (^OSNotificationOpenedBlock)(OSNotificationOpenedResult * _Nonnull
3939
Public API.
4040
*/
4141
@protocol OSNotifications <NSObject>
42-
+ (BOOL)permission;
43-
+ (BOOL)canRequestPermission;
42+
+ (BOOL)permission NS_REFINED_FOR_SWIFT;
43+
+ (BOOL)canRequestPermission NS_REFINED_FOR_SWIFT;
4444
+ (void)setNotificationWillShowInForegroundHandler:(OSNotificationWillShowInForegroundBlock _Nullable)block;
4545
+ (void)setNotificationOpenedHandler:(OSNotificationOpenedBlock _Nullable)block;
4646
+ (void)requestPermission:(OSUserResponseBlock _Nullable )block;
4747
+ (void)requestPermission:(OSUserResponseBlock _Nullable )block fallbackToSettings:(BOOL)fallback;
48-
+ (void)registerForProvisionalAuthorization:(OSUserResponseBlock _Nullable )block;
49-
+ (void)addPermissionObserver:(NSObject<OSPermissionObserver>*_Nonnull)observer;
50-
+ (void)removePermissionObserver:(NSObject<OSPermissionObserver>*_Nonnull)observer;
48+
+ (void)registerForProvisionalAuthorization:(OSUserResponseBlock _Nullable )block NS_REFINED_FOR_SWIFT;
49+
+ (void)addPermissionObserver:(NSObject<OSPermissionObserver>*_Nonnull)observer NS_REFINED_FOR_SWIFT;
50+
+ (void)removePermissionObserver:(NSObject<OSPermissionObserver>*_Nonnull)observer NS_REFINED_FOR_SWIFT;
5151
+ (void)clearAll;
5252
@end
5353

iOS_SDK/OneSignalSDK/OneSignalOutcomes/OneSignalOutcomes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
@protocol OSSession <NSObject>
4949
+ (void)addOutcome:(NSString * _Nonnull)name;
5050
+ (void)addUniqueOutcome:(NSString * _Nonnull)name;
51-
+ (void)addOutcomeWithValue:(NSString * _Nonnull)name value:(NSNumber * _Nonnull)value;
51+
+ (void)addOutcomeWithValue:(NSString * _Nonnull)name value:(NSNumber * _Nonnull)value NS_REFINED_FOR_SWIFT;
52+
5253
@end
5354

5455
@interface OSOutcomes : NSObject <OSSession>

iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,22 @@ NS_SWIFT_NAME(login(externalId:token:));
9090
+ (Class<OSDebug>)Debug NS_REFINED_FOR_SWIFT;
9191

9292
#pragma mark Privacy Consent
93-
+ (void)setPrivacyConsent:(BOOL)granted;
94-
+ (BOOL)getPrivacyConsent;
93+
+ (void)setPrivacyConsent:(BOOL)granted NS_REFINED_FOR_SWIFT;
94+
+ (BOOL)getPrivacyConsent NS_REFINED_FOR_SWIFT;
9595
/**
9696
* Tells your application if privacy consent is still needed from the current device.
9797
* Consent should be provided prior to the invocation of `initialize` to ensure compliance.
9898
*/
99-
+ (BOOL)requiresPrivacyConsent;
100-
+ (void)setRequiresPrivacyConsent:(BOOL)required;
101-
102-
#pragma mark Permission, Subscription, and Email Observers
99+
+ (BOOL)requiresPrivacyConsent NS_REFINED_FOR_SWIFT;
100+
+ (void)setRequiresPrivacyConsent:(BOOL)required NS_REFINED_FOR_SWIFT;
103101

104102
#pragma mark In-App Messaging
105103
+ (Class<OSInAppMessages>)InAppMessages NS_REFINED_FOR_SWIFT;
106104

107105
#pragma mark Location
108106
+ (Class<OSLocation>)Location NS_REFINED_FOR_SWIFT;
109107

110-
#pragma mark Outcomes
108+
#pragma mark Session
111109
+ (Class<OSSession>)Session NS_REFINED_FOR_SWIFT;
112110

113111
#pragma mark Extension

iOS_SDK/OneSignalSDK/Source/OneSignalLocation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ typedef struct os_last_location {
4545
@protocol OSLocation <NSObject>
4646
// - Request and track user's location
4747
+ (void)requestPermission;
48-
+ (void)setShared:(BOOL)enable;
49-
+ (BOOL)isShared;
48+
+ (void)setShared:(BOOL)enable NS_REFINED_FOR_SWIFT;
49+
+ (BOOL)isShared NS_REFINED_FOR_SWIFT;
5050
@end
5151

5252
@interface OneSignalLocation : NSObject<OSLocation>

iOS_SDK/OneSignalSDK/Source/OneSignalSwiftInterface.swift

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,72 @@ public extension OneSignal {
5555
static var Location: OSLocation.Type {
5656
return __location()
5757
}
58+
59+
static var requiresPrivacyConsent: Bool {
60+
get {
61+
return __requiresPrivacyConsent()
62+
}
63+
set {
64+
__setRequiresPrivacyConsent(newValue)
65+
}
66+
}
67+
68+
static var privacyConsent: Bool {
69+
get {
70+
return __getPrivacyConsent()
71+
}
72+
set {
73+
__setPrivacyConsent(newValue)
74+
}
75+
}
76+
}
77+
78+
public extension OSInAppMessages {
79+
static var Paused: Bool {
80+
get {
81+
return __paused()
82+
}
83+
set {
84+
__paused(newValue)
85+
}
86+
}
87+
}
88+
89+
public extension OSSession {
90+
static func addOutcome(_ name: String, _ value: NSNumber) {
91+
__addOutcome(withValue: name, value: value)
92+
}
93+
}
94+
95+
public extension OSNotifications {
96+
static var permission: Bool {
97+
return __permission()
98+
}
99+
100+
static var canRequestPermission: Bool {
101+
return __canRequestPermission()
102+
}
103+
104+
static func registerForProvisionalAuthorization(_ block: OSUserResponseBlock?) {
105+
return __register(forProvisionalAuthorization: block)
106+
}
107+
108+
static func addPermissionObserver(_ observer: OSPermissionObserver) {
109+
return __add(observer)
110+
}
111+
112+
static func removePermissionObserver(_ observer: OSPermissionObserver) {
113+
return __remove(observer)
114+
}
115+
}
116+
117+
public extension OSLocation {
118+
static var isShared: Bool {
119+
get {
120+
return __isShared()
121+
}
122+
set {
123+
__setShared(newValue)
124+
}
125+
}
58126
}

iOS_SDK/OneSignalSDK/UnitTests/UserModelSwiftTests.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@
2828
import XCTest
2929
import OneSignalFramework
3030

31-
extension OSInAppMessages {
32-
static var Paused: Bool {
33-
get {
34-
return __paused()
35-
}
36-
set {
37-
__paused(newValue)
38-
}
39-
}
40-
}
41-
4231
// Non-class type 'OSPushSubscriptionTestObserver' cannot conform to class protocol 'OSPushSubscriptionObserver'
4332
// ^ Cannot use a struct for an OSPushSubscriptionObserver
4433

0 commit comments

Comments
 (0)