com.onesignal.unity.ios 2.14.6 → 3.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/Editor/BuildPostProcessor.cs +297 -0
  2. package/Editor/{PostProcessBuildPlayer_iOS.cs.meta → BuildPostProcessor.cs.meta} +0 -0
  3. package/Editor/OneSignalIOSDependencies.xml +5 -0
  4. package/Editor/OneSignalIOSDependencies.xml.meta +3 -0
  5. package/Editor/PBXProjectExtensions.cs +52 -0
  6. package/Editor/PBXProjectExtensions.cs.meta +3 -0
  7. package/Runtime/AssemblyInfo.cs +28 -1
  8. package/Runtime/OneSignal.iOS.asmdef +4 -3
  9. package/Runtime/OneSignalIOS.Callbacks.cs +174 -0
  10. package/Runtime/OneSignalIOS.Callbacks.cs.meta +3 -0
  11. package/Runtime/OneSignalIOS.Interface.cs +99 -0
  12. package/Runtime/OneSignalIOS.Interface.cs.meta +3 -0
  13. package/Runtime/OneSignalIOS.cs +268 -457
  14. package/Runtime/OneSignalIOS.cs.meta +3 -10
  15. package/Runtime/OneSignalIOSInit.cs +39 -9
  16. package/Runtime/Plugins/iOS/Info.plist.meta +1 -3
  17. package/Runtime/Plugins/iOS/NotificationService.swift +25 -0
  18. package/Runtime/Plugins/iOS/{NotificationService.m.meta → NotificationService.swift.meta} +5 -4
  19. package/Runtime/Plugins/iOS/OneSignalUnityBridge.mm +417 -0
  20. package/Runtime/Plugins/iOS/{OneSignal.h.meta → OneSignalUnityBridge.mm.meta} +16 -5
  21. package/Runtime/Utilities/Later.cs +64 -0
  22. package/Runtime/Utilities/Later.cs.meta +11 -0
  23. package/Runtime/Utilities.meta +3 -0
  24. package/package.json +2 -2
  25. package/Editor/PostProcessBuildPlayer_iOS.cs +0 -399
  26. package/Runtime/Plugins/iOS/NotificationService.h +0 -13
  27. package/Runtime/Plugins/iOS/NotificationService.h.meta +0 -26
  28. package/Runtime/Plugins/iOS/NotificationService.m +0 -40
  29. package/Runtime/Plugins/iOS/OneSignal.h +0 -617
  30. package/Runtime/Plugins/iOS/OneSignalUnityRuntime.m +0 -542
  31. package/Runtime/Plugins/iOS/OneSignalUnityRuntime.m.meta +0 -24
  32. package/Runtime/Plugins/iOS/libOneSignal.a +0 -0
  33. package/Runtime/Plugins/iOS/libOneSignal.a.meta +0 -21
@@ -1,10 +1,3 @@
1
- fileFormatVersion: 2
2
- guid: e70d413bef86c430281efe706fde20d4
3
- MonoImporter:
4
- serializedVersion: 2
5
- defaultReferences: []
6
- executionOrder: 0
7
- icon: {instanceID: 0}
8
- userData:
9
- assetBundleName:
10
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 2af5d93546b14794833229faccc49504
3
+ timeCreated: 1631804853
@@ -1,12 +1,42 @@
1
- using UnityEngine;
1
+ /*
2
+ * Modified MIT License
3
+ *
4
+ * Copyright 2022 OneSignal
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * 1. The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * 2. All copies of substantial portions of the Software may only be used in connection
17
+ * with services provided by OneSignal.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ * THE SOFTWARE.
26
+ */
2
27
 
28
+ #if UNITY_IOS && !UNITY_EDITOR
29
+ using UnityEngine;
3
30
 
4
- static class OneSignalIOSInit
5
- {
6
- [RuntimeInitializeOnLoadMethod]
7
- public static void Init()
8
- {
9
- if (!Application.isEditor)
10
- OneSignal.RegisterPlatform(new OneSignalIOS());
31
+ namespace OneSignalSDK {
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ internal static class OneSignalIOSInit {
36
+ [RuntimeInitializeOnLoadMethod] public static void Init() {
37
+ if (!OneSignal.DidInitialize)
38
+ OneSignal.Default = new OneSignalIOS();
39
+ }
11
40
  }
12
- }
41
+ }
42
+ #endif
@@ -1,7 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 62568c0a8f70c45dcad44d91384c32f4
3
- timeCreated: 1522803471
4
- licenseType: Free
2
+ guid: bd7ca7986c645411eaf0b2237fe8525e
5
3
  DefaultImporter:
6
4
  externalObjects: {}
7
5
  userData:
@@ -0,0 +1,25 @@
1
+ import UserNotifications
2
+ import OneSignal
3
+
4
+ class NotificationService: UNNotificationServiceExtension {
5
+ var contentHandler: ((UNNotificationContent) -> Void)?
6
+ var receivedRequest: UNNotificationRequest!
7
+ var bestAttemptContent: UNMutableNotificationContent?
8
+
9
+ override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
10
+ self.receivedRequest = request
11
+ self.contentHandler = contentHandler
12
+ self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
13
+
14
+ if let bestAttemptContent = bestAttemptContent {
15
+ OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)
16
+ }
17
+ }
18
+
19
+ override func serviceExtensionTimeWillExpire() {
20
+ if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
21
+ OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
22
+ contentHandler(bestAttemptContent)
23
+ }
24
+ }
25
+ }
@@ -1,14 +1,15 @@
1
1
  fileFormatVersion: 2
2
- guid: 4677c01ecce0a4366a990873a5fd6e02
3
- timeCreated: 1522803673
4
- licenseType: Free
2
+ guid: 934e62d9afbb344909f2c8d6376f459d
5
3
  PluginImporter:
6
4
  externalObjects: {}
7
5
  serializedVersion: 2
8
6
  iconMap: {}
9
7
  executionOrder: {}
8
+ defineConstraints: []
10
9
  isPreloaded: 0
11
- isOverridable: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 1
12
13
  platformData:
13
14
  - first:
14
15
  Any:
@@ -0,0 +1,417 @@
1
+ /*
2
+ * Modified MIT License
3
+ *
4
+ * Copyright 2022 OneSignal
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * 1. The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * 2. All copies of substantial portions of the Software may only be used in connection
17
+ * with services provided by OneSignal.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ * THE SOFTWARE.
26
+ */
27
+
28
+ #import <OneSignal/OneSignal.h>
29
+
30
+ typedef void (*BooleanResponseDelegate)(int hashCode, bool response);
31
+ typedef void (*StringResponseDelegate)(int hashCode, const char* response);
32
+
33
+ typedef void (*BooleanListenerDelegate)(bool response);
34
+ typedef void (*StringListenerDelegate)(const char* response);
35
+ typedef void (*StateListenerDelegate)(const char* current, const char* previous);
36
+
37
+ typedef bool (*NotificationWillShowInForegroundDelegate)(const char* notification);
38
+
39
+ /*
40
+ * Helpers
41
+ */
42
+
43
+ #define CALLBACK(value) callback(hashCode, value)
44
+ #define TO_NSSTRING(cstr) cstr ? [NSString stringWithUTF8String:cstr] : nil
45
+
46
+ template <typename TObj>
47
+ TObj objFromJsonString(const char* jsonString) {
48
+ NSData* jsonData = [[NSString stringWithUTF8String:jsonString] dataUsingEncoding:NSUTF8StringEncoding];
49
+ NSError* error = nil;
50
+ TObj arr = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
51
+
52
+ if (error != nil)
53
+ return nil;
54
+
55
+ return arr;
56
+ }
57
+
58
+ const char* jsonStringFromDictionary(NSDictionary *dictionary) {
59
+ NSError *error;
60
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:&error];
61
+ NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
62
+ return [jsonString UTF8String];
63
+ }
64
+
65
+ /*
66
+ * Observer singleton for global callbacks
67
+ */
68
+
69
+ @interface OneSignalObserver : NSObject <OSPermissionObserver,
70
+ OSSubscriptionObserver,
71
+ OSEmailSubscriptionObserver,
72
+ OSSMSSubscriptionObserver,
73
+ OSInAppMessageLifecycleHandler>
74
+
75
+ + (instancetype) sharedObserver;
76
+ @property StateListenerDelegate permissionDelegate;
77
+ @property StateListenerDelegate subscriptionDelegate;
78
+ @property StateListenerDelegate emailDelegate;
79
+ @property StateListenerDelegate smsDelegate;
80
+ @property StringListenerDelegate iamWillDisplayDelegate;
81
+ @property StringListenerDelegate iamDidDisplayDelegate;
82
+ @property StringListenerDelegate iamWillDismissDelegate;
83
+ @property StringListenerDelegate iamDidDismissDelegate;
84
+
85
+ @end
86
+
87
+ @implementation OneSignalObserver
88
+
89
+ + (instancetype) sharedObserver {
90
+ static dispatch_once_t pred = 0;
91
+ static id _sharedObject = nil;
92
+ dispatch_once(&pred, ^{
93
+ _sharedObject = [[self alloc] init];
94
+ });
95
+ return _sharedObject;
96
+ }
97
+
98
+ - (instancetype) init {
99
+ if (self = [super init]) {
100
+ [OneSignal setInAppMessageLifecycleHandler:self];
101
+ [OneSignal addPermissionObserver:self];
102
+ [OneSignal addSubscriptionObserver:self];
103
+ [OneSignal addEmailSubscriptionObserver:self];
104
+ [OneSignal addSMSSubscriptionObserver:self];
105
+ }
106
+
107
+ return self;
108
+ }
109
+
110
+ - (void)onOSPermissionChanged:(OSPermissionStateChanges * _Nonnull)stateChanges {
111
+ if (_permissionDelegate != nil) {
112
+ auto curr = jsonStringFromDictionary([[stateChanges to] toDictionary]);
113
+ auto prev = jsonStringFromDictionary([[stateChanges from] toDictionary]);
114
+ _permissionDelegate(curr, prev);
115
+ }
116
+ }
117
+
118
+ - (void)onOSSubscriptionChanged:(OSSubscriptionStateChanges * _Nonnull)stateChanges {
119
+ if (_subscriptionDelegate != nil) {
120
+ auto curr = jsonStringFromDictionary([[stateChanges to] toDictionary]);
121
+ auto prev = jsonStringFromDictionary([[stateChanges from] toDictionary]);
122
+ _subscriptionDelegate(curr, prev);
123
+ }
124
+ }
125
+
126
+ - (void)onOSEmailSubscriptionChanged:(OSEmailSubscriptionStateChanges * _Nonnull)stateChanges {
127
+ if (_emailDelegate != nil) {
128
+ auto curr = jsonStringFromDictionary([[stateChanges to] toDictionary]);
129
+ auto prev = jsonStringFromDictionary([[stateChanges from] toDictionary]);
130
+ _emailDelegate(curr, prev);
131
+ }
132
+ }
133
+
134
+ - (void)onOSSMSSubscriptionChanged:(OSSMSSubscriptionStateChanges * _Nonnull)stateChanges {
135
+ if (_smsDelegate != nil) {
136
+ auto curr = jsonStringFromDictionary([[stateChanges to] toDictionary]);
137
+ auto prev = jsonStringFromDictionary([[stateChanges from] toDictionary]);
138
+ _smsDelegate(curr, prev);
139
+ }
140
+ }
141
+
142
+ - (void)onWillDisplayInAppMessage:(OSInAppMessage *)message {
143
+ if (_iamWillDisplayDelegate != nil)
144
+ _iamWillDisplayDelegate([message.messageId UTF8String]);
145
+ }
146
+
147
+ - (void)onDidDisplayInAppMessage:(OSInAppMessage *)message {
148
+ if (_iamDidDisplayDelegate != nil)
149
+ _iamDidDisplayDelegate([message.messageId UTF8String]);
150
+ }
151
+
152
+ - (void)onWillDismissInAppMessage:(OSInAppMessage *)message {
153
+ if (_iamWillDismissDelegate != nil)
154
+ _iamWillDismissDelegate([message.messageId UTF8String]);
155
+ }
156
+
157
+ - (void)onDidDismissInAppMessage:(OSInAppMessage *)message {
158
+ if (_iamDidDismissDelegate != nil)
159
+ _iamDidDismissDelegate([message.messageId UTF8String]);
160
+ }
161
+
162
+ @end
163
+
164
+ /*
165
+ * Bridge methods
166
+ */
167
+
168
+ extern "C" {
169
+
170
+ void _setNotificationReceivedCallback(NotificationWillShowInForegroundDelegate callback) {
171
+ [OneSignal setNotificationWillShowInForegroundHandler:^(OSNotification *notification, OSNotificationDisplayResponse completion) {
172
+ NSString *stringResponse = [notification stringify];
173
+ bool shouldDisplay = callback([stringResponse UTF8String]);
174
+ completion(shouldDisplay ? notification : nil);
175
+ }];
176
+ }
177
+
178
+ void _setNotificationOpenedCallback(StringListenerDelegate callback) {
179
+ [OneSignal setNotificationOpenedHandler:^(OSNotificationOpenedResult * _Nonnull result) {
180
+ NSString *stringResponse = [result stringify];
181
+ callback([stringResponse UTF8String]);
182
+ }];
183
+ }
184
+
185
+ void _setInAppMessageWillDisplayCallback(StringListenerDelegate callback) {
186
+ [[OneSignalObserver sharedObserver] setIamWillDisplayDelegate:callback];
187
+ }
188
+
189
+ void _setInAppMessageDidDisplayCallback(StringListenerDelegate callback) {
190
+ [[OneSignalObserver sharedObserver] setIamDidDisplayDelegate:callback];
191
+ }
192
+
193
+ void _setInAppMessageWillDismissCallback(StringListenerDelegate callback) {
194
+ [[OneSignalObserver sharedObserver] setIamWillDismissDelegate:callback];
195
+ }
196
+
197
+ void _setInAppMessageDidDismissCallback(StringListenerDelegate callback) {
198
+ [[OneSignalObserver sharedObserver] setIamDidDismissDelegate:callback];
199
+ }
200
+
201
+ void _setInAppMessageClickedCallback(StringListenerDelegate callback) {
202
+ [OneSignal setInAppMessageClickHandler:^(OSInAppMessageAction * _Nonnull action) {
203
+ callback(jsonStringFromDictionary([action jsonRepresentation]));
204
+ }];
205
+ }
206
+
207
+ void _setPermissionStateChangedCallback(StateListenerDelegate callback) {
208
+ [[OneSignalObserver sharedObserver] setPermissionDelegate:callback];
209
+ }
210
+
211
+ void _setSubscriptionStateChangedCallback(StateListenerDelegate callback) {
212
+ [[OneSignalObserver sharedObserver] setSubscriptionDelegate:callback];
213
+ }
214
+
215
+ void _setEmailSubscriptionStateChangedCallback(StateListenerDelegate callback) {
216
+ [[OneSignalObserver sharedObserver] setEmailDelegate:callback];
217
+ }
218
+
219
+ void _setSMSSubscriptionStateChangedCallback(StateListenerDelegate callback) {
220
+ [[OneSignalObserver sharedObserver] setSmsDelegate:callback];
221
+ }
222
+
223
+ const char* _getDeviceState() {
224
+ auto deviceState = [OneSignal getDeviceState];
225
+ auto stateStr = jsonStringFromDictionary([deviceState jsonRepresentation]);
226
+ return strdup(stateStr);
227
+ }
228
+
229
+ void _setLogLevel(int logLevel, int alertLevel) {
230
+ [OneSignal setLogLevel:(ONE_S_LOG_LEVEL) logLevel
231
+ visualLevel:(ONE_S_LOG_LEVEL) alertLevel];
232
+ }
233
+
234
+ void _setPrivacyConsent(bool consent) {
235
+ [OneSignal consentGranted: consent];
236
+ }
237
+
238
+ bool _getPrivacyConsent() {
239
+ return false; // todo - doesn't exist
240
+ }
241
+
242
+ void _setRequiresPrivacyConsent(bool required) {
243
+ [OneSignal setRequiresUserPrivacyConsent: required];
244
+ }
245
+
246
+ bool _getRequiresPrivacyConsent() {
247
+ return [OneSignal requiresUserPrivacyConsent];
248
+ }
249
+
250
+ void _initialize(const char* appId) {
251
+ [OneSignal setAppId:TO_NSSTRING(appId)];
252
+ [OneSignal initWithLaunchOptions:nil];
253
+ }
254
+
255
+ void _promptForPushNotificationsWithUserResponse(int hashCode, BooleanResponseDelegate callback) {
256
+ [OneSignal promptForPushNotificationsWithUserResponse:^(BOOL accepted) {
257
+ CALLBACK(accepted);
258
+ }];
259
+ }
260
+
261
+ void _postNotification(const char* optionsJson, int hashCode, StringResponseDelegate callback) {
262
+ NSDictionary *options = objFromJsonString<NSDictionary*>(optionsJson);
263
+
264
+ [OneSignal postNotification:options onSuccess:^(NSDictionary *result) {
265
+ CALLBACK(jsonStringFromDictionary(result));
266
+ } onFailure:^(NSError *error) {
267
+ CALLBACK(NULL);
268
+ }];
269
+ }
270
+
271
+ void _setTrigger(const char* key, const char* value) {
272
+ [OneSignal addTrigger:TO_NSSTRING(key) withValue:TO_NSSTRING(value)];
273
+ }
274
+
275
+ void _setTriggers(const char* triggersJson) {
276
+ NSDictionary *triggers = objFromJsonString<NSDictionary*>(triggersJson);
277
+ [OneSignal addTriggers:triggers];
278
+ }
279
+
280
+ void _removeTrigger(const char* key) {
281
+ [OneSignal removeTriggerForKey:TO_NSSTRING(key)];
282
+ }
283
+
284
+ void _removeTriggers(const char* triggersJson) {
285
+ NSArray *triggers = objFromJsonString<NSArray*>(triggersJson);
286
+ [OneSignal removeTriggersForKeys:triggers];
287
+ }
288
+
289
+ const char* _getTrigger(const char* key) {
290
+ id value = [OneSignal getTriggerValueForKey:TO_NSSTRING(key)];
291
+ NSString *asString = [NSString stringWithFormat:@"%@", value];
292
+ return strdup([asString UTF8String]);
293
+ }
294
+
295
+ const char* _getTriggers() {
296
+ NSDictionary *triggers = [OneSignal getTriggers];
297
+ return strdup(jsonStringFromDictionary(triggers));
298
+ }
299
+
300
+ void _setInAppMessagesArePaused(bool paused) {
301
+ [OneSignal pauseInAppMessages:paused];
302
+ }
303
+
304
+ bool _getInAppMessagesArePaused() {
305
+ return [OneSignal isInAppMessagingPaused];
306
+ }
307
+
308
+ void _sendTag(const char* name, const char* value, int hashCode, BooleanResponseDelegate callback) {
309
+ [OneSignal sendTag:TO_NSSTRING(name)
310
+ value:TO_NSSTRING(value)
311
+ onSuccess:^(NSDictionary *result) { CALLBACK(YES); }
312
+ onFailure:^(NSError *error) { CALLBACK(NO); }];
313
+ }
314
+
315
+ void _sendTags(const char* tagsJson, int hashCode, BooleanResponseDelegate callback) {
316
+ NSDictionary *tags = objFromJsonString<NSDictionary*>(tagsJson);
317
+
318
+ [OneSignal sendTags:tags
319
+ onSuccess:^(NSDictionary *result) { CALLBACK(YES); }
320
+ onFailure:^(NSError *error) { CALLBACK(NO); }];
321
+ }
322
+
323
+ void _getTags(int hashCode, StringResponseDelegate callback) {
324
+ [OneSignal getTags:^(NSDictionary *result) {
325
+ CALLBACK(jsonStringFromDictionary(result));
326
+ } onFailure:^(NSError *error) {
327
+ NSLog(@"[Onesignal] Could not get tags");
328
+ CALLBACK(nil);
329
+ }];
330
+ }
331
+
332
+ void _deleteTag(const char* name, int hashCode, BooleanResponseDelegate callback) {
333
+ [OneSignal deleteTag:TO_NSSTRING(name)
334
+ onSuccess:^(NSDictionary *result) { CALLBACK(YES); }
335
+ onFailure:^(NSError *error) { CALLBACK(NO); }];
336
+ }
337
+
338
+ void _deleteTags(const char* tagsJson, int hashCode, BooleanResponseDelegate callback) {
339
+ NSArray *tags = objFromJsonString<NSArray*>(tagsJson);
340
+
341
+ if (tags == nil) {
342
+ NSLog(@"[Onesignal] Could not parse tags to delete");
343
+ CALLBACK(NO);
344
+ }
345
+
346
+ [OneSignal deleteTags:tags
347
+ onSuccess:^(NSDictionary *result) { CALLBACK(YES); }
348
+ onFailure:^(NSError *error) { CALLBACK(NO); }];
349
+ }
350
+
351
+ void _setExternalUserId(const char* externalId, const char* authHash, int hashCode, BooleanResponseDelegate callback) {
352
+ [OneSignal setExternalUserId:TO_NSSTRING(externalId)
353
+ withExternalIdAuthHashToken:TO_NSSTRING(authHash)
354
+ withSuccess:^(NSDictionary *results) { CALLBACK(YES); }
355
+ withFailure:^(NSError *error) { CALLBACK(NO); }];
356
+ }
357
+
358
+ void _setEmail(const char* email, const char* authHash, int hashCode, BooleanResponseDelegate callback) {
359
+ [OneSignal setEmail:TO_NSSTRING(email)
360
+ withEmailAuthHashToken:TO_NSSTRING(authHash)
361
+ withSuccess:^{ CALLBACK(YES); }
362
+ withFailure:^(NSError *error) { CALLBACK(NO); }];
363
+ }
364
+
365
+ void _setSMSNumber(const char* smsNumber, const char* authHash, int hashCode, BooleanResponseDelegate callback) {
366
+ [OneSignal setSMSNumber:TO_NSSTRING(smsNumber)
367
+ withSMSAuthHashToken:TO_NSSTRING(authHash)
368
+ withSuccess:^(NSDictionary *results) { CALLBACK(YES); }
369
+ withFailure:^(NSError *error) { CALLBACK(NO); }];
370
+ }
371
+
372
+ void _logoutEmail(int hashCode, BooleanResponseDelegate callback) {
373
+ [OneSignal logoutEmailWithSuccess:^{ CALLBACK(YES); }
374
+ withFailure:^(NSError *error) { CALLBACK(NO); }];
375
+ }
376
+
377
+ void _logoutSMSNumber(int hashCode, BooleanResponseDelegate callback) {
378
+ [OneSignal logoutSMSNumberWithSuccess:^(NSDictionary *results) { CALLBACK(YES); }
379
+ withFailure:^(NSError *error) { CALLBACK(NO); }];
380
+ }
381
+
382
+ void _setLanguage(const char* languageCode, int hashCode, BooleanResponseDelegate callback) {
383
+ [OneSignal setLanguage:TO_NSSTRING(languageCode)
384
+ withSuccess:^{ CALLBACK(YES); }
385
+ withFailure:^(NSError *error) { CALLBACK(NO); }];
386
+ }
387
+
388
+ void _promptLocation() {
389
+ [OneSignal promptLocation];
390
+ }
391
+
392
+ void _setShareLocation(bool share) {
393
+ [OneSignal setLocationShared:share];
394
+ }
395
+
396
+ bool _getShareLocation() {
397
+ return [OneSignal isLocationShared];
398
+ }
399
+
400
+ void _sendOutcome(const char* name, int hashCode, BooleanResponseDelegate callback) {
401
+ [OneSignal sendOutcome:TO_NSSTRING(name)
402
+ onSuccess:^(OSOutcomeEvent *outcome) { CALLBACK(outcome != nil); }];
403
+ }
404
+
405
+ void _sendUniqueOutcome(const char* name, int hashCode, BooleanResponseDelegate callback) {
406
+ [OneSignal sendUniqueOutcome:TO_NSSTRING(name)
407
+ onSuccess:^(OSOutcomeEvent *outcome) { CALLBACK(outcome != nil); }];
408
+ }
409
+
410
+ void _sendOutcomeWithValue(const char* name, float value, int hashCode, BooleanResponseDelegate callback) {
411
+ [OneSignal sendOutcomeWithValue:TO_NSSTRING(name)
412
+ value:@(value)
413
+ onSuccess:^(OSOutcomeEvent *outcome) { CALLBACK(outcome != nil); }];
414
+ }
415
+ }
416
+
417
+
@@ -1,19 +1,20 @@
1
1
  fileFormatVersion: 2
2
- guid: acee050ac0f234be5a68a8a16f4b7324
3
- timeCreated: 1521138854
4
- licenseType: Free
2
+ guid: 20ec11046074a1b46b1f65140b2f2897
5
3
  PluginImporter:
6
4
  externalObjects: {}
7
5
  serializedVersion: 2
8
6
  iconMap: {}
9
7
  executionOrder: {}
8
+ defineConstraints: []
10
9
  isPreloaded: 0
11
- isOverridable: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 1
12
13
  platformData:
13
14
  - first:
14
15
  Any:
15
16
  second:
16
- enabled: 1
17
+ enabled: 0
17
18
  settings: {}
18
19
  - first:
19
20
  Editor: Editor
@@ -21,6 +22,16 @@ PluginImporter:
21
22
  enabled: 0
22
23
  settings:
23
24
  DefaultValueInitialized: true
25
+ - first:
26
+ iPhone: iOS
27
+ second:
28
+ enabled: 1
29
+ settings: {}
30
+ - first:
31
+ tvOS: tvOS
32
+ second:
33
+ enabled: 1
34
+ settings: {}
24
35
  userData:
25
36
  assetBundleName:
26
37
  assetBundleVariant:
@@ -0,0 +1,64 @@
1
+ using System;
2
+ using System.Runtime.CompilerServices;
3
+ using System.Threading.Tasks;
4
+
5
+ namespace Laters {
6
+ /// <summary>For referencing <see cref="ILater{TResult}"/> generically</summary>
7
+ public interface ILater {}
8
+
9
+ /// <summary>Read-only interface for a standard <see cref="Later{TResult}"/></summary>
10
+ public interface ILater<TResult> : ILater {
11
+ event Action<TResult> OnComplete;
12
+ TaskAwaiter<TResult> GetAwaiter();
13
+ }
14
+
15
+ /// <summary>Basic Later for passing a single type to callbacks and awaiters</summary>
16
+ public class Later<TResult> : BaseLater<TResult> {
17
+ public void Complete(TResult result) => _complete(result);
18
+ }
19
+
20
+ /// <summary>Separated implementation so the derivations can offer different methods for completion</summary>
21
+ public abstract class BaseLater<TResult> : ILater<TResult> {
22
+ public event Action<TResult> OnComplete {
23
+ remove => _onComplete -= value;
24
+ add {
25
+ if (_isComplete)
26
+ _onComplete += value;
27
+ else if (value != null)
28
+ value(_result);
29
+ }
30
+ }
31
+
32
+ public TaskAwaiter<TResult> GetAwaiter() {
33
+ if (_completionSource != null)
34
+ return _completionSource.Task.GetAwaiter();
35
+
36
+ _completionSource = new TaskCompletionSource<TResult>();
37
+
38
+ if (_isComplete)
39
+ _completionSource.TrySetResult(_result);
40
+ else
41
+ _onComplete += result => _completionSource.TrySetResult(result);
42
+
43
+ return _completionSource.Task.GetAwaiter();
44
+ }
45
+
46
+ protected void _complete(TResult result) {
47
+ if (_isComplete)
48
+ return;
49
+
50
+ _result = result;
51
+
52
+ var toComplete = _onComplete;
53
+ _onComplete = null;
54
+
55
+ _isComplete = true;
56
+ toComplete?.Invoke(_result);
57
+ }
58
+
59
+ private TaskCompletionSource<TResult> _completionSource;
60
+ private event Action<TResult> _onComplete;
61
+ private bool _isComplete = false;
62
+ private TResult _result;
63
+ }
64
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 31d5b079bcd7e4c498b08a7297233460
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: ad307fca52b64505a63c5ee75cc1a719
3
+ timeCreated: 1632500910
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "com.onesignal.unity.ios",
3
3
  "displayName": "OneSignal Unity SDK - iOS",
4
- "version": "2.14.6",
4
+ "version": "3.0.0-beta.4",
5
5
  "unity": "2018.4",
6
6
  "description": "OneSignal is the market leader in customer engagement, powering mobile push, web push, email, and in-app messages.",
7
7
  "dependencies": {
8
- "com.onesignal.unity.core": "2.14.6"
8
+ "com.onesignal.unity.core": "3.0.0-beta.4"
9
9
  },
10
10
  "keywords": [
11
11
  "push-notifications",