Skip to content

Commit f4547ee

Browse files
committed
WP8.1 support + other fixes
* Added support for Windows Phone 8.1 projects. * Fixed Android issue where postNotification was not formatting UTF-8 notifications correctly. * Fixed iOS bug where notifications would clear when opening / resuming the app. - Notifications will still be cleared in this way when a badge is set. - This is due to an iOS limitation where clearing the badge count has a side effect of clearing all notifications from the app. - iOS 6 & 7 - When a notification is opened all other notifications from the app will still be cleared. - This logic remains otherwise notifications can be tapped on multiple times. * Fixed bug where if content-available was set the notification would be marked opened when received and again when it was opened.
1 parent 6804c08 commit f4547ee

18 files changed

+360
-24
lines changed
Binary file not shown.

UnityOneSignalExample/Assets/Plugins/OneSignal/OneSignal.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8)
28+
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_WP_8_1)
2929
#define ONESIGNAL_PLATFORM
3030
#endif
3131

3232
#if !UNITY_EDITOR && UNITY_ANDROID
3333
#define ANDROID_ONLY
3434
#endif
3535

36-
#if ONESIGNAL_PLATFORM && !UNITY_WP8
36+
#if ONESIGNAL_PLATFORM && !UNITY_WP8 && !UNITY_WP_8_1
3737
#define SUPPORTS_LOGGING
3838
#endif
3939

@@ -95,11 +95,13 @@ public static void Init(string appId, string googleProjectNumber, NotificationRe
9595
#elif UNITY_IPHONE
9696
oneSignalPlatform = new OneSignalIOS(gameObjectName, appId, autoRegister, logLevel, visualLogLevel);
9797
#elif UNITY_WP8
98-
oneSignalPlatform = new OneSignalWP(appId);
98+
oneSignalPlatform = new OneSignalWP80(appId);
99+
#elif UNITY_WP_8_1
100+
oneSignalPlatform = new OneSignalWPWNS(appId);
99101
#endif
100102
notificationDelegate = inNotificationDelegate;
101103

102-
#if !UNITY_WP8
104+
#if !UNITY_WP8 && !UNITY_WP_8_1
103105
GameObject go = new GameObject(gameObjectName);
104106
go.AddComponent<OneSignal>();
105107
DontDestroyOnLoad(go);

UnityOneSignalExample/Assets/Plugins/OneSignal/OneSignalWP.cs renamed to UnityOneSignalExample/Assets/Plugins/OneSignal/OneSignalWP80.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
using System.Collections;
3232
using System.Collections.Generic;
3333

34-
class OneSignalWP : OneSignalPlatform {
34+
class OneSignalWP80 : OneSignalPlatform {
3535

3636
public OneSignalWP(string appId) {
37-
OneSignalSDK.OneSignal.Init(appId, (message, inAdditionalData, isActive) => {
37+
OneSignalSDK_WP80.OneSignal.Init(appId, (message, inAdditionalData, isActive) => {
3838
if (OneSignal.notificationDelegate != null) {
3939
Dictionary<string, object> additionalData = null;
4040
if (inAdditionalData != null)
@@ -45,33 +45,33 @@ public OneSignalWP(string appId) {
4545
}
4646

4747
public void SendTag(string tagName, string tagValue) {
48-
OneSignalSDK.OneSignal.SendTag(tagName, tagValue);
48+
OneSignalSDK_WP80.OneSignal.SendTag(tagName, tagValue);
4949
}
5050

5151
public void SendTags(IDictionary<string, string> tags) {
52-
OneSignalSDK.OneSignal.SendTags(tags.ToDictionary(pair => pair.Key, pair=>(object)pair.Value));
52+
OneSignalSDK_WP80.OneSignal.SendTags(tags.ToDictionary(pair => pair.Key, pair=>(object)pair.Value));
5353
}
5454

5555
public void SendPurchase(double amount) {
56-
OneSignalSDK.OneSignal.SendPurchase(amount);
56+
OneSignalSDK_WP80.OneSignal.SendPurchase(amount);
5757
}
5858

5959
public void GetTags() {
60-
OneSignalSDK.OneSignal.GetTags((tags) => {
60+
OneSignalSDK_WP80.OneSignal.GetTags((tags) => {
6161
OneSignal.tagsReceivedDelegate(tags.ToDictionary(pair => pair.Key, pair=>(object)pair.Value));
6262
});
6363
}
6464

6565
public void DeleteTag(string key) {
66-
OneSignalSDK.OneSignal.DeleteTag(key);
66+
OneSignalSDK_WP80.OneSignal.DeleteTag(key);
6767
}
6868

6969
public void DeleteTags(IList<string> key) {
70-
OneSignalSDK.OneSignal.DeleteTags(key);
70+
OneSignalSDK_WP80.OneSignal.DeleteTags(key);
7171
}
7272

7373
public void IdsAvailable() {
74-
OneSignalSDK.OneSignal.GetIdsAvailable((playerId, channelUri) => {
74+
OneSignalSDK_WP80.OneSignal.GetIdsAvailable((playerId, channelUri) => {
7575
OneSignal.idsAvailableDelegate(playerId, channelUri);
7676
});
7777
}

UnityOneSignalExample/Assets/Plugins/OneSignal/OneSignalWP.cs.meta renamed to UnityOneSignalExample/Assets/Plugins/OneSignal/OneSignalWP80.cs.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* Modified MIT License
3+
*
4+
* Copyright 2015 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 UnityEngine;
29+
using System.Linq;
30+
using System.Collections;
31+
using System.Collections.Generic;
32+
33+
#if UNITY_WP_8_1 && !UNITY_EDITOR
34+
35+
public class OneSignalWPWNS : OneSignalPlatform {
36+
37+
public OneSignalWPWNS(string appId) {
38+
OneSignalSDK_WP_WNS.ExternalInitUnity.Init(appId, (message, inAdditionalData, isActive) => {
39+
if (OneSignal.notificationDelegate != null) {
40+
Dictionary<string, object> additionalData = null;
41+
if (inAdditionalData != null)
42+
additionalData = inAdditionalData.ToDictionary(pair => pair.Key, pair=>(object)pair.Value);
43+
OneSignal.notificationDelegate(message, additionalData, isActive);
44+
}
45+
});
46+
}
47+
48+
public void SendTag(string tagName, string tagValue) {
49+
OneSignalSDK_WP_WNS.OneSignal.SendTag(tagName, tagValue);
50+
}
51+
52+
public void SendTags(IDictionary<string, string> tags) {
53+
OneSignalSDK_WP_WNS.OneSignal.SendTags(tags.ToDictionary(pair => pair.Key, pair=>(object)pair.Value));
54+
}
55+
56+
public void SendPurchase(double amount) {
57+
OneSignalSDK_WP_WNS.OneSignal.SendPurchase(amount);
58+
}
59+
60+
public void GetTags() {
61+
OneSignalSDK_WP_WNS.OneSignal.GetTags((tags) => {
62+
OneSignal.tagsReceivedDelegate(tags.ToDictionary(pair => pair.Key, pair=>(object)pair.Value));
63+
});
64+
}
65+
66+
public void DeleteTag(string key) {
67+
OneSignalSDK_WP_WNS.OneSignal.DeleteTag(key);
68+
}
69+
70+
public void DeleteTags(IList<string> key) {
71+
OneSignalSDK_WP_WNS.OneSignal.DeleteTags(key);
72+
}
73+
74+
public void IdsAvailable() {
75+
OneSignalSDK_WP_WNS.OneSignal.GetIdsAvailable((playerId, channelUri) => {
76+
OneSignal.idsAvailableDelegate(playerId, channelUri);
77+
});
78+
}
79+
80+
// Not available the WP SDK.
81+
public void EnableInAppAlertNotification(bool enable) { }
82+
83+
// Not available in WP SDK.
84+
public void SetSubscription(bool enable) {}
85+
86+
// Not available in WP SDK.
87+
public void PostNotification(Dictionary<string, object> data) { }
88+
89+
// Doesn't apply to Windows Phone: The Callback is setup in the constructor so this is never called.
90+
public void FireNotificationReceivedEvent(string jsonString, OneSignal.NotificationReceived notificationReceived) {}
91+
92+
public void OnApplicationPause(bool paused) { } // Doesn't apply to Windows Phone: The Native SDK auto handles this.
93+
public void RegisterForPushNotifications() { } // Doesn't apply to Windows Phone: The Native SDK always registers.
94+
95+
public void SetLogLevel(OneSignal.LOG_LEVEL logLevel, OneSignal.LOG_LEVEL visualLevel) {} // The Native SDK does not implement this.
96+
}
97+
#endif

UnityOneSignalExample/Assets/Plugins/OneSignal/OneSignalWPWNS.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.10.2
1+
1.11.0
Binary file not shown.

UnityOneSignalExample/Assets/Plugins/OneSignalSDK_WP_WNS.dll.meta

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityOneSignalExample/Assets/Plugins/WSA.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

UnityOneSignalExample/Assets/Plugins/WSA/Newtonsoft.Json.dll.meta

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

0 commit comments

Comments
 (0)