Skip to content

Commit 44eb3ca

Browse files
committed
Fix GetPermissionSubscriptionState()
• Resolves an issue in the OneSignal.getPermissionSubscriptionState() function that caused it to produce an error. • The email subscription state was not being properly parsed
1 parent 5d9dfb8 commit 44eb3ca

File tree

5 files changed

+162
-6
lines changed

5 files changed

+162
-6
lines changed
Binary file not shown.

OneSignalExample/Assets/OneSignal/src/OneSignalIOS.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,22 @@ public OSSubscriptionState parseOSSubscriptionState(object stateDict) {
248248
public OSEmailSubscriptionState parseOSEmailSubscriptionState(object stateDict) {
249249
var stateDictCasted = stateDict as Dictionary<string, object>;
250250

251-
var state = new OSEmailSubscriptionState();
252-
state.emailUserId = stateDictCasted["emailUserId"] as string;
253-
state.emailAddress = stateDictCasted["emailAddress"] as string;
254-
state.subscribed = Convert.ToBoolean(stateDictCasted["subscribed"]);
251+
var state = new OSEmailSubscriptionState ();
252+
253+
if (stateDictCasted.ContainsKey ("emailUserId")) {
254+
state.emailUserId = stateDictCasted ["emailUserId"] as string;
255+
} else {
256+
state.emailUserId = "";
257+
}
258+
259+
if (stateDictCasted.ContainsKey ("emailAddress")) {
260+
state.emailAddress = stateDictCasted ["emailAddress"] as string;
261+
} else {
262+
state.emailAddress = "";
263+
}
264+
265+
266+
state.subscribed = stateDictCasted.ContainsKey("emailUserId") && stateDictCasted["emailUserId"] != null;
255267

256268
return state;
257269
}

OneSignalExample/Assets/OneSignal/src/OneSignalPlatformHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ internal static OSPermissionSubscriptionState parsePermissionSubscriptionState(O
3535
var state = new OSPermissionSubscriptionState();
3636
state.permissionStatus = platform.parseOSPermissionState(stateDict["permissionStatus"]);
3737
state.subscriptionStatus = platform.parseOSSubscriptionState(stateDict["subscriptionStatus"]);
38-
state.emailSubscriptionStatus = platform.parseOSEmailSubscriptionState (stateDict ["emailSubscriptionStatus"]);
38+
39+
if (stateDict.ContainsKey("emailSubscriptionStatus"))
40+
state.emailSubscriptionStatus = platform.parseOSEmailSubscriptionState (stateDict ["emailSubscriptionStatus"]);
3941

4042
return state;
4143
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "29x29",
16+
"scale" : "1x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "29x29",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"size" : "29x29",
26+
"scale" : "3x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "40x40",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"size" : "40x40",
36+
"scale" : "3x"
37+
},
38+
{
39+
"size" : "57x57",
40+
"idiom" : "iphone",
41+
"filename" : "Icon.png",
42+
"scale" : "1x"
43+
},
44+
{
45+
"size" : "57x57",
46+
"idiom" : "iphone",
47+
"filename" : "[email protected]",
48+
"scale" : "2x"
49+
},
50+
{
51+
"size" : "60x60",
52+
"idiom" : "iphone",
53+
"filename" : "Icon-120.png",
54+
"scale" : "2x"
55+
},
56+
{
57+
"size" : "60x60",
58+
"idiom" : "iphone",
59+
"filename" : "Icon-180.png",
60+
"scale" : "3x"
61+
},
62+
{
63+
"idiom" : "ipad",
64+
"size" : "20x20",
65+
"scale" : "1x"
66+
},
67+
{
68+
"idiom" : "ipad",
69+
"size" : "20x20",
70+
"scale" : "2x"
71+
},
72+
{
73+
"idiom" : "ipad",
74+
"size" : "29x29",
75+
"scale" : "1x"
76+
},
77+
{
78+
"idiom" : "ipad",
79+
"size" : "29x29",
80+
"scale" : "2x"
81+
},
82+
{
83+
"idiom" : "ipad",
84+
"size" : "40x40",
85+
"scale" : "1x"
86+
},
87+
{
88+
"idiom" : "ipad",
89+
"size" : "40x40",
90+
"scale" : "2x"
91+
},
92+
{
93+
"idiom" : "ipad",
94+
"size" : "50x50",
95+
"scale" : "1x"
96+
},
97+
{
98+
"idiom" : "ipad",
99+
"size" : "50x50",
100+
"scale" : "2x"
101+
},
102+
{
103+
"size" : "72x72",
104+
"idiom" : "ipad",
105+
"filename" : "Icon-72.png",
106+
"scale" : "1x"
107+
},
108+
{
109+
"size" : "72x72",
110+
"idiom" : "ipad",
111+
"filename" : "Icon-144.png",
112+
"scale" : "2x"
113+
},
114+
{
115+
"size" : "76x76",
116+
"idiom" : "ipad",
117+
"filename" : "Icon-76.png",
118+
"scale" : "1x"
119+
},
120+
{
121+
"size" : "76x76",
122+
"idiom" : "ipad",
123+
"filename" : "Icon-152.png",
124+
"scale" : "2x"
125+
},
126+
{
127+
"size" : "83.5x83.5",
128+
"idiom" : "ipad",
129+
"filename" : "Icon-167.png",
130+
"scale" : "2x"
131+
},
132+
{
133+
"idiom" : "ios-marketing",
134+
"size" : "1024x1024",
135+
"scale" : "1x"
136+
}
137+
],
138+
"info" : {
139+
"version" : 1,
140+
"author" : "xcode"
141+
}
142+
}

OneSignalExample/ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ PlayerSettings:
161161
Android: com.onesignal.example
162162
Standalone: unity.OneSignal.OneSignal Example
163163
Tizen: com.onesignal.example
164-
iOS: com.onesignal.example
164+
iOS: com.testapp.brad
165165
tvOS: com.onesignal.example
166166
buildNumber:
167167
iOS: 0

0 commit comments

Comments
 (0)