com.onesignal.unity.ios 3.0.8 → 5.0.0-beta.1
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.
- package/Editor/BuildPostProcessor.cs +4 -2
- package/Editor/OneSignaliOSDependencies.xml +5 -0
- package/Editor/OneSignaliOSDependencies.xml.meta +7 -0
- package/Editor/PBXProjectExtensions.cs +1 -1
- package/Runtime/OneSignaliOS.cs +178 -0
- package/Runtime/OneSignaliOS.cs.meta +11 -0
- package/Runtime/{OneSignalIOSInit.cs → OneSignaliOSInit.cs} +3 -3
- package/Runtime/OneSignaliOSInit.cs.meta +11 -0
- package/Runtime/Plugins/iOS/NotificationService.swift +1 -1
- package/Runtime/Plugins/iOS/OneSignalBridgeUtil.h +35 -0
- package/Runtime/Plugins/iOS/OneSignalBridgeUtil.h.meta +27 -0
- package/Runtime/Plugins/iOS/OneSignalBridgeUtil.mm +49 -0
- package/Runtime/Plugins/iOS/OneSignalBridgeUtil.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridge.mm +36 -383
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeDebug.mm +40 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeDebug.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeInAppMessages.mm +167 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeInAppMessages.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeLocation.mm +44 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeLocation.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm +124 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeSession.mm +55 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeSession.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeUser.mm +197 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeUser.mm.meta +37 -0
- package/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm +4 -2
- package/Runtime/Utilities/WaitingProxy.cs +52 -0
- package/Runtime/Utilities/WaitingProxy.cs.meta +11 -0
- package/Runtime/iOSDebugManager.cs +57 -0
- package/Runtime/iOSDebugManager.cs.meta +11 -0
- package/Runtime/iOSInAppMessagesManager.cs +118 -0
- package/Runtime/iOSInAppMessagesManager.cs.meta +11 -0
- package/Runtime/iOSLocationManager.cs +48 -0
- package/Runtime/iOSLocationManager.cs.meta +11 -0
- package/Runtime/iOSNotificationsManager.cs +148 -0
- package/Runtime/iOSNotificationsManager.cs.meta +11 -0
- package/Runtime/iOSPushSubscription.cs +81 -0
- package/Runtime/iOSPushSubscription.cs.meta +11 -0
- package/Runtime/iOSSessionManager.cs +47 -0
- package/Runtime/iOSSessionManager.cs.meta +11 -0
- package/Runtime/iOSUserManager.cs +106 -0
- package/Runtime/iOSUserManager.cs.meta +11 -0
- package/package.json +2 -2
- package/Editor/OneSignalIOSDependencies.xml +0 -5
- package/Editor/OneSignalIOSDependencies.xml.meta +0 -3
- package/Runtime/OneSignalIOS.Callbacks.cs +0 -181
- package/Runtime/OneSignalIOS.Callbacks.cs.meta +0 -3
- package/Runtime/OneSignalIOS.Interface.cs +0 -102
- package/Runtime/OneSignalIOS.Interface.cs.meta +0 -3
- package/Runtime/OneSignalIOS.Mappings.cs +0 -96
- package/Runtime/OneSignalIOS.Mappings.cs.meta +0 -3
- package/Runtime/OneSignalIOS.cs +0 -257
- package/Runtime/OneSignalIOS.cs.meta +0 -3
- package/Runtime/OneSignalIOSInit.cs.meta +0 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 0c86b66fd87ab44ae9986e58f07a6b1c
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 1
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 0
|
|
23
|
+
settings:
|
|
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: {}
|
|
35
|
+
userData:
|
|
36
|
+
assetBundleName:
|
|
37
|
+
assetBundleVariant:
|
|
@@ -0,0 +1,44 @@
|
|
|
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 <OneSignalNotifications/OneSignalNotifications.h>
|
|
29
|
+
#import <OneSignalUser/OneSignalUser-Swift.h>
|
|
30
|
+
#import <OneSignalFramework/OneSignalFramework.h>
|
|
31
|
+
|
|
32
|
+
extern "C" {
|
|
33
|
+
bool _locationGetIsShared() {
|
|
34
|
+
return [OneSignal.Location isShared];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void _locationSetIsShared(bool shared) {
|
|
38
|
+
[OneSignal.Location setShared:shared];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
void _locationRequestPermission() {
|
|
42
|
+
[OneSignal.Location requestPermission];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 95da40b428fdb488e8bfc2c2a55734f5
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 1
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 0
|
|
23
|
+
settings:
|
|
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: {}
|
|
35
|
+
userData:
|
|
36
|
+
assetBundleName:
|
|
37
|
+
assetBundleVariant:
|
|
@@ -0,0 +1,124 @@
|
|
|
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 <OneSignalNotifications/OneSignalNotifications.h>
|
|
29
|
+
#import <OneSignalUser/OneSignalUser-Swift.h>
|
|
30
|
+
#import <OneSignalFramework/OneSignalFramework.h>
|
|
31
|
+
#import "OneSignalBridgeUtil.h"
|
|
32
|
+
|
|
33
|
+
typedef void (*BooleanResponseDelegate)(int hashCode, bool response);
|
|
34
|
+
typedef void (*StringListenerDelegate)(const char* response);
|
|
35
|
+
typedef void (*StateListenerDelegate)(const char* current);
|
|
36
|
+
typedef bool (*NotificationWillShowDelegate)(const char* notification);
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* Helpers
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
#define CALLBACK(value) callback(hashCode, value)
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* Observer singleton for global callbacks
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
@interface OneSignalNotificationsObserver : NSObject <OSPermissionObserver>
|
|
49
|
+
|
|
50
|
+
+ (instancetype) sharedNotificationsObserver;
|
|
51
|
+
@property StateListenerDelegate permissionDelegate;
|
|
52
|
+
|
|
53
|
+
@end
|
|
54
|
+
|
|
55
|
+
@implementation OneSignalNotificationsObserver
|
|
56
|
+
|
|
57
|
+
+ (instancetype) sharedNotificationsObserver {
|
|
58
|
+
static dispatch_once_t pred = 0;
|
|
59
|
+
static id _sharedObject = nil;
|
|
60
|
+
dispatch_once(&pred, ^{
|
|
61
|
+
_sharedObject = [[self alloc] init];
|
|
62
|
+
});
|
|
63
|
+
return _sharedObject;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
- (instancetype) init {
|
|
67
|
+
if (self = [super init]) {
|
|
68
|
+
[OneSignal.Notifications addPermissionObserver:self];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return self;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
- (void)onOSPermissionChanged:(OSPermissionState*)state {
|
|
75
|
+
if (_permissionDelegate != nil) {
|
|
76
|
+
auto curr = jsonStringFromDictionary([state jsonRepresentation]);
|
|
77
|
+
_permissionDelegate(curr);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@end
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
* Bridge methods
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
extern "C" {
|
|
88
|
+
bool _notificationsGetPermission() {
|
|
89
|
+
return [OneSignal.Notifications permission];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/*bool _notificationsGetCanRequestPermission() {
|
|
93
|
+
return [OneSignal.Notifications canRequestPermission];
|
|
94
|
+
}*/
|
|
95
|
+
|
|
96
|
+
void _notificationsClearAll() {
|
|
97
|
+
[OneSignal.Notifications clearAll];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void _notificationsRequestPermission(bool fallbackToSettings, int hashCode, BooleanResponseDelegate callback) {
|
|
101
|
+
[OneSignal.Notifications requestPermission:^(BOOL accepted) {
|
|
102
|
+
CALLBACK(accepted);
|
|
103
|
+
} fallbackToSettings:fallbackToSettings];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void _notificationsAddPermissionStateChangedCallback(StateListenerDelegate callback) {
|
|
107
|
+
[[OneSignalNotificationsObserver sharedNotificationsObserver] setPermissionDelegate:callback];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
void _notificationsSetWillShowHandler(NotificationWillShowDelegate callback) {
|
|
111
|
+
[OneSignal.Notifications setNotificationWillShowInForegroundHandler:^(OSNotification *notification, OSNotificationDisplayResponse completion) {
|
|
112
|
+
NSString *stringResponse = [notification stringify];
|
|
113
|
+
bool shouldDisplay = callback([stringResponse UTF8String]);
|
|
114
|
+
completion(shouldDisplay ? notification : nil);
|
|
115
|
+
}];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void _notificationsSetOpenedHandler(StringListenerDelegate callback) {
|
|
119
|
+
[OneSignal.Notifications setNotificationOpenedHandler:^(OSNotificationOpenedResult * _Nonnull result) {
|
|
120
|
+
NSString *stringResponse = [result stringify];
|
|
121
|
+
callback([stringResponse UTF8String]);
|
|
122
|
+
}];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: d7bc033d72f9a45e7b7270c6374a5abc
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 1
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 0
|
|
23
|
+
settings:
|
|
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: {}
|
|
35
|
+
userData:
|
|
36
|
+
assetBundleName:
|
|
37
|
+
assetBundleVariant:
|
|
@@ -0,0 +1,55 @@
|
|
|
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 <OneSignalNotifications/OneSignalNotifications.h>
|
|
29
|
+
#import <OneSignalUser/OneSignalUser-Swift.h>
|
|
30
|
+
#import <OneSignalFramework/OneSignalFramework.h>
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
* Helpers
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
#define TO_NSSTRING(cstr) cstr ? [NSString stringWithUTF8String:cstr] : nil
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* Bridge methods
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
extern "C" {
|
|
43
|
+
void _sessionAddOutcome(const char* name) {
|
|
44
|
+
[OneSignal.Session addOutcome:TO_NSSTRING(name)];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void _sessionAddUniqueOutcome(const char* name) {
|
|
48
|
+
[OneSignal.Session addUniqueOutcome:TO_NSSTRING(name)];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void _sessionAddOutcomeWithValue(const char* name, float value) {
|
|
52
|
+
[OneSignal.Session addOutcomeWithValue:TO_NSSTRING(name)
|
|
53
|
+
value:@(value)];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 0418db384a17d4487a32e3eb8114c398
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 1
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 0
|
|
23
|
+
settings:
|
|
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: {}
|
|
35
|
+
userData:
|
|
36
|
+
assetBundleName:
|
|
37
|
+
assetBundleVariant:
|
|
@@ -0,0 +1,197 @@
|
|
|
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 <OneSignalNotifications/OneSignalNotifications.h>
|
|
29
|
+
#import <OneSignalUser/OneSignalUser-Swift.h>
|
|
30
|
+
#import <OneSignalFramework/OneSignalFramework.h>
|
|
31
|
+
#import "OneSignalBridgeUtil.h"
|
|
32
|
+
|
|
33
|
+
typedef void (*StateListenerDelegate)(const char* current, const char* previous);
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
* Helpers
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
#define TO_NSSTRING(cstr) cstr ? [NSString stringWithUTF8String:cstr] : nil
|
|
40
|
+
|
|
41
|
+
template <typename TObj>
|
|
42
|
+
TObj objFromJsonString2(const char* jsonString) {
|
|
43
|
+
NSData* jsonData = [[NSString stringWithUTF8String:jsonString] dataUsingEncoding:NSUTF8StringEncoding];
|
|
44
|
+
NSError* error = nil;
|
|
45
|
+
TObj arr = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
|
|
46
|
+
|
|
47
|
+
if (error != nil)
|
|
48
|
+
return nil;
|
|
49
|
+
|
|
50
|
+
return arr;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* Observer singleton for global callbacks
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
@interface OneSignalUserObserver : NSObject <OSPushSubscriptionObserver>
|
|
58
|
+
|
|
59
|
+
+ (instancetype) sharedUserObserver;
|
|
60
|
+
@property StateListenerDelegate pushSubscriptionDelegate;
|
|
61
|
+
|
|
62
|
+
@end
|
|
63
|
+
|
|
64
|
+
@implementation OneSignalUserObserver
|
|
65
|
+
|
|
66
|
+
+ (instancetype) sharedUserObserver {
|
|
67
|
+
static dispatch_once_t pred = 0;
|
|
68
|
+
static id _sharedObject = nil;
|
|
69
|
+
dispatch_once(&pred, ^{
|
|
70
|
+
_sharedObject = [[self alloc] init];
|
|
71
|
+
});
|
|
72
|
+
return _sharedObject;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
- (instancetype) init {
|
|
76
|
+
if (self = [super init]) {
|
|
77
|
+
[OneSignal.User.pushSubscription addObserver:self];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return self;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
- (void)onOSPushSubscriptionChangedWithStateChanges:(OSPushSubscriptionStateChanges*)stateChanges {
|
|
84
|
+
if (_pushSubscriptionDelegate != nil) {
|
|
85
|
+
auto curr = jsonStringFromDictionary([[stateChanges to] jsonRepresentation]);
|
|
86
|
+
auto prev = jsonStringFromDictionary([[stateChanges from] jsonRepresentation]);
|
|
87
|
+
_pushSubscriptionDelegate(curr, prev);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@end
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* Bridge methods
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
extern "C" {
|
|
98
|
+
void _userSetLanguage(const char* languageCode) {
|
|
99
|
+
[OneSignal.User setLanguage:TO_NSSTRING(languageCode)];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/*id<OSPushSubscription> _userGetPushSubscription() {
|
|
103
|
+
return OneSignal.User.pushSubscription;
|
|
104
|
+
}*/
|
|
105
|
+
|
|
106
|
+
void _userAddAlias(const char* aliasLabel, const char* aliasId) {
|
|
107
|
+
[OneSignal.User addAliasWithLabel:TO_NSSTRING(aliasLabel)
|
|
108
|
+
id:TO_NSSTRING(aliasId)];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void _userAddAliases(const char* aliasesJson) {
|
|
112
|
+
NSDictionary *aliases = objFromJsonString2<NSDictionary*>(aliasesJson);
|
|
113
|
+
|
|
114
|
+
[OneSignal.User addAliases:aliases];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
void _userRemoveAlias(const char* aliasLabel) {
|
|
118
|
+
[OneSignal.User removeAlias:TO_NSSTRING(aliasLabel)];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
void _userRemoveAliases(const char* aliasesJson) {
|
|
122
|
+
NSArray *aliases = objFromJsonString2<NSArray*>(aliasesJson);
|
|
123
|
+
|
|
124
|
+
if (aliases == nil) {
|
|
125
|
+
NSLog(@"[Onesignal] Could not parse aliases to delete");
|
|
126
|
+
//CALLBACK(NO);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
[OneSignal.User removeAliases:aliases];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
void _userAddEmail(const char* email) {
|
|
133
|
+
[OneSignal.User addEmail:TO_NSSTRING(email)];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
void _userRemoveEmail(const char* email) {
|
|
137
|
+
[OneSignal.User removeEmail:TO_NSSTRING(email)];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
void _userAddSms(const char* smsNumber) {
|
|
141
|
+
[OneSignal.User addSms:TO_NSSTRING(smsNumber)];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
void _userRemoveSms(const char* smsNumber) {
|
|
145
|
+
[OneSignal.User removeSms:TO_NSSTRING(smsNumber)];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
void _userAddTag(const char* key, const char* value) {
|
|
149
|
+
[OneSignal.User addTagWithKey:TO_NSSTRING(key)
|
|
150
|
+
value:TO_NSSTRING(value)];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
void _userAddTags(const char* tagsJson) {
|
|
154
|
+
NSDictionary *tags = objFromJsonString2<NSDictionary*>(tagsJson);
|
|
155
|
+
|
|
156
|
+
[OneSignal.User addTags:tags];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
void _userRemoveTag(const char* key) {
|
|
160
|
+
[OneSignal.User removeTag:TO_NSSTRING(key)];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
void _userRemoveTags(const char* tagsJson) {
|
|
164
|
+
NSArray *tags = objFromJsonString2<NSArray*>(tagsJson);
|
|
165
|
+
|
|
166
|
+
if (tags == nil) {
|
|
167
|
+
NSLog(@"[Onesignal] Could not parse tags to delete");
|
|
168
|
+
//CALLBACK(NO);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
[OneSignal.User removeTags:tags];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const char* _pushSubscriptionGetId() {
|
|
175
|
+
return [OneSignal.User.pushSubscription.id UTF8String];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const char* _pushSubscriptionGetToken() {
|
|
179
|
+
return [OneSignal.User.pushSubscription.token UTF8String];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
bool _pushSubscriptionGetOptedIn() {
|
|
183
|
+
return OneSignal.User.pushSubscription.optedIn;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
void _pushSubscriptionOptIn() {
|
|
187
|
+
[OneSignal.User.pushSubscription optIn];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
void _pushSubscriptionOptOut() {
|
|
191
|
+
[OneSignal.User.pushSubscription optOut];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
void _pushSubscriptionAddStateChangedCallback(StateListenerDelegate callback) {
|
|
195
|
+
[[OneSignalUserObserver sharedUserObserver] setPushSubscriptionDelegate:callback];
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: ee831af790307428db8e2a8afc69b253
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 1
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 0
|
|
23
|
+
settings:
|
|
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: {}
|
|
35
|
+
userData:
|
|
36
|
+
assetBundleName:
|
|
37
|
+
assetBundleVariant:
|
|
@@ -25,8 +25,10 @@
|
|
|
25
25
|
* THE SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
+
#import <OneSignalNotifications/OneSignalNotifications.h>
|
|
29
|
+
#import <OneSignalUser/OneSignalUser-Swift.h>
|
|
30
|
+
#import <OneSignalFramework/OneSignalFramework.h>
|
|
28
31
|
#import "UIApplication+OneSignalUnity.h"
|
|
29
|
-
#import <OneSignal/OneSignal.h>
|
|
30
32
|
#import <objc/runtime.h>
|
|
31
33
|
|
|
32
34
|
// from OneSignalSelectorHelpers.m
|
|
@@ -94,7 +96,7 @@ static bool swizzled = false;
|
|
|
94
96
|
|
|
95
97
|
- (BOOL)oneSignalApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
96
98
|
[OneSignal setMSDKType:@"unity"];
|
|
97
|
-
[OneSignal
|
|
99
|
+
[OneSignal setLaunchOptions:launchOptions];
|
|
98
100
|
|
|
99
101
|
if ([self respondsToSelector:@selector(oneSignalApplication:didFinishLaunchingWithOptions:)])
|
|
100
102
|
return [self oneSignalApplication:application didFinishLaunchingWithOptions:launchOptions];
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
using Laters;
|
|
29
|
+
using System.Collections.Generic;
|
|
30
|
+
|
|
31
|
+
namespace OneSignalSDK.iOS.Utilities {
|
|
32
|
+
internal static class WaitingProxy {
|
|
33
|
+
private static readonly Dictionary<int, ILater> WaitingProxies = new Dictionary<int, ILater>();
|
|
34
|
+
|
|
35
|
+
public static (Later<TResult> proxy, int hashCode) _setupProxy<TResult>() {
|
|
36
|
+
var proxy = new Later<TResult>();
|
|
37
|
+
var hashCode = proxy.GetHashCode();
|
|
38
|
+
WaitingProxies[hashCode] = proxy;
|
|
39
|
+
return (proxy, hashCode);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static void ResolveCallbackProxy<TResponse>(int hashCode, TResponse response) {
|
|
43
|
+
if (!WaitingProxies.ContainsKey(hashCode))
|
|
44
|
+
return;
|
|
45
|
+
|
|
46
|
+
if (WaitingProxies[hashCode] is Later<TResponse> later)
|
|
47
|
+
later.Complete(response);
|
|
48
|
+
|
|
49
|
+
WaitingProxies.Remove(hashCode);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|