This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6995220
commit 55a4efd
Showing
1,259 changed files
with
259,592 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
internal static class JsonHelpers | ||
{ | ||
internal static int GetStatusCode(JObject jRoot) | ||
{ | ||
return jRoot.Value<int>("status_code"); | ||
} | ||
|
||
internal static string GetStatusMessage(JObject jRoot) | ||
{ | ||
return jRoot.Value<string>("status_message"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class AppEventRequest : BaseRequest | ||
{ | ||
[JsonProperty("goal")] | ||
public string Goal { get; set; } | ||
|
||
[JsonProperty("count")] | ||
public int Count { get; set; } | ||
|
||
public override string GetMethodName() { return "applicationEvent"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class AppOpenRequest : BaseRequest | ||
{ | ||
public override string GetMethodName() { return "applicationOpen"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal abstract class BaseRequest | ||
{ | ||
[JsonProperty("application")] | ||
public string AppId { get; set; } | ||
|
||
// Note: this requires ID_CAP_IDENTITY_DEVICE | ||
// to be added to the capabilities of the WMAppManifest | ||
// this will then warn users in marketplace | ||
[JsonProperty("hwid")] | ||
public string HardwareId | ||
{ | ||
get { return SDKHelpers.GetDeviceUniqueId(); } | ||
} | ||
|
||
[JsonProperty("v")] | ||
public string SDKVersion | ||
{ | ||
//returns SDK version | ||
get { return "2.3"; } | ||
} | ||
|
||
[JsonIgnore] | ||
public string ErrorMessage { get; set; } | ||
|
||
public virtual void ParseResponse(JObject jRoot) { } | ||
|
||
public abstract string GetMethodName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class GeozoneRequest : BaseRequest | ||
{ | ||
[JsonProperty("lat")] | ||
public double Lat { get; set; } | ||
|
||
[JsonProperty("lng")] | ||
public double Lon { get; set; } | ||
|
||
public override string GetMethodName() { return "getNearestZone"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class GetTagsRequest : BaseRequest | ||
{ | ||
[JsonIgnore] | ||
public JObject Tags { get; set; } | ||
|
||
public override void ParseResponse(JObject jRoot) | ||
{ | ||
Tags = jRoot["response"].Value<JObject>("result"); | ||
} | ||
|
||
public override string GetMethodName() { return "getTags"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Threading; | ||
using Newtonsoft.Json; | ||
using System.Threading.Tasks; | ||
using Windows.UI.Xaml.Controls; | ||
using System.Text.RegularExpressions; | ||
using Windows.ApplicationModel.Core; | ||
using Windows.UI.Core; | ||
using Windows.ApplicationModel; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class RegistrationRequest : BaseRequest | ||
{ | ||
[JsonProperty("device_type")] | ||
public int DeviceType | ||
{ | ||
get { return Constants.DeviceType; } | ||
} | ||
|
||
[JsonProperty("push_token")] | ||
public string PushToken { get; set; } | ||
|
||
[JsonProperty("language")] | ||
public string Language | ||
{ | ||
get { return System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; } | ||
} | ||
|
||
[JsonProperty("timezone")] | ||
public double Timezone | ||
{ | ||
get { return TimeZoneInfo.Local.BaseUtcOffset.TotalSeconds; } | ||
} | ||
|
||
[JsonProperty("app_version")] | ||
public string AppVersion | ||
{ | ||
get | ||
{ | ||
var version = Package.Current.Id.Version; | ||
return String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision); | ||
} | ||
} | ||
|
||
public override string GetMethodName() { return "registerDevice"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class SendBadgeRequest : BaseRequest | ||
{ | ||
[JsonProperty("badge")] | ||
public int Badge { get; set; } | ||
|
||
public override string GetMethodName() { return "setBadge"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class SendPurchaseRequest : BaseRequest | ||
{ | ||
[JsonProperty("productIdentifier")] | ||
public string ProductIdentifier { get; set; } | ||
|
||
[JsonProperty("quantity")] | ||
public int Quantity { get; set; } | ||
|
||
[JsonProperty("transactionDate")] | ||
public int DateTimeStamp { get; set; } | ||
|
||
[JsonProperty("price")] | ||
public double Price { get; set; } | ||
|
||
[JsonProperty("currency")] | ||
public string Currency { get; set; } | ||
|
||
public override string GetMethodName() { return "setPurchase"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class SetTagsRequest : BaseRequest | ||
{ | ||
[JsonProperty("tags")] | ||
public JObject Tags { get; set; } | ||
|
||
public void BuildTags(IEnumerable<KeyValuePair<string, object>> tagList) | ||
{ | ||
JObject tags = new JObject(); | ||
foreach (var tag in tagList) | ||
{ | ||
tags.Add(new JProperty(tag.Key, tag.Value)); | ||
} | ||
|
||
Tags = tags; | ||
} | ||
|
||
public void BuildTags(String[] key, object[] values) | ||
{ | ||
JObject tags = new JObject(); | ||
|
||
int lenght = key.Length >= values.Length ? values.Length : key.Length; | ||
for (int i = 0; i < lenght; i++) | ||
{ | ||
tags.Add(new JProperty(key[i], values[i])); | ||
} | ||
|
||
Tags = tags; | ||
} | ||
|
||
public override string GetMethodName() { return "setTags"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class StatisticRequest : BaseRequest | ||
{ | ||
[JsonProperty("hash", NullValueHandling = NullValueHandling.Ignore)] | ||
public string Hash { get; set; } | ||
|
||
public override string GetMethodName() { return "pushStat"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Threading; | ||
using Newtonsoft.Json; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
[JsonObject] | ||
internal class UnregisterRequest : BaseRequest | ||
{ | ||
public override string GetMethodName() { return "unregisterDevice"; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text.RegularExpressions; | ||
using Windows.Networking.Connectivity; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace PushSDK.Classes | ||
{ | ||
internal static class SDKHelpers | ||
{ | ||
private static string _deviceId; | ||
|
||
public static string GetDeviceUniqueId() | ||
{ | ||
if (_deviceId == null) | ||
{ | ||
try | ||
{ | ||
_deviceId = NetworkInformation.GetConnectionProfiles(). | ||
Where(p => p.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.ConstrainedInternetAccess). | ||
Select(p => p.NetworkAdapter.NetworkAdapterId). | ||
OrderBy(p => p).First().ToString(); | ||
} | ||
catch | ||
{ | ||
_deviceId = BitConverter.ToString(Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null).Id.ToArray()); | ||
} | ||
} | ||
|
||
return _deviceId; | ||
} | ||
|
||
internal static ToastPush ParsePushData(String args) | ||
{ | ||
try | ||
{ | ||
args = System.Net.WebUtility.UrlDecode(args); | ||
args = args.Replace("/PushSDK;component/Controls/PushPage.xaml?", ""); | ||
|
||
JObject jRoot = JObject.Parse(args); | ||
|
||
ToastPush toast = new ToastPush(); | ||
|
||
if (jRoot["pushwoosh"] == null) | ||
return toast; | ||
|
||
jRoot = (JObject)jRoot["pushwoosh"]; | ||
|
||
if (jRoot["content"] != null) | ||
toast.Content = jRoot["content"].ToString(); | ||
|
||
if (jRoot["p"] != null) | ||
toast.Hash = jRoot["p"].ToString(); | ||
|
||
if (jRoot["h"] != null) | ||
toast.HtmlId = jRoot["h"].ToObject<int>(); | ||
|
||
if (jRoot["data"] != null) | ||
toast.UserData = jRoot["data"].ToString(); | ||
|
||
try | ||
{ | ||
if (jRoot["l"] != null) | ||
toast.Url = new Uri(jRoot["l"].ToString(), UriKind.Absolute); | ||
} | ||
catch { } | ||
|
||
return toast; | ||
} | ||
catch { } | ||
|
||
return null; | ||
} | ||
|
||
private static Dictionary<string,string> ParseQueryString(string s) | ||
{ | ||
var list = new Dictionary<string, string>(); | ||
|
||
// remove anything other than query string from url | ||
if (s.Contains("?")) | ||
{ | ||
s = s.Substring(s.IndexOf('?') + 1); | ||
} | ||
|
||
foreach (string vp in Regex.Split(s, "&")) | ||
{ | ||
string[] singlePair = Regex.Split(vp, "="); | ||
if (singlePair.Length == 2) | ||
list[singlePair[0]] = singlePair[1]; | ||
else | ||
// only one key with no value specified in query string | ||
list[singlePair[0]] = string.Empty; | ||
} | ||
return list; | ||
} | ||
} | ||
} |
Oops, something went wrong.