-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from OneSignal/outcomes_release
Update for outcomes and release 3.6.0
- Loading branch information
Showing
22 changed files
with
330 additions
and
114 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
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
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
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,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Com.OneSignal.Abstractions | ||
{ | ||
public class OSOutcomeEvent | ||
{ | ||
|
||
public enum OSSession | ||
{ | ||
DIRECT, | ||
INDIRECT, | ||
UNATTRIBUTED, | ||
DISABLED | ||
} | ||
|
||
public OSSession session = OSSession.DISABLED; | ||
public List<string> notificationIds = new List<string>(); | ||
public string name = ""; | ||
public long timestamp = 0; | ||
public double weight = 0; | ||
|
||
public OSOutcomeEvent() {} | ||
|
||
public OSOutcomeEvent(Dictionary<string, object> outcomeObject) | ||
{ | ||
// session; | ||
if (outcomeObject.ContainsKey("session")) | ||
this.session = SessionFromString(outcomeObject["session"] as string); | ||
|
||
// notificationIds | ||
if (outcomeObject.ContainsKey("notification_ids")) { | ||
List<object> idObjects = outcomeObject["notification_ids"] as List<object>; | ||
List<string> ids = new List<string>(); | ||
foreach (var id in idObjects) | ||
ids.Add(id.ToString()); | ||
|
||
this.notificationIds = ids; | ||
} | ||
|
||
// id | ||
if (outcomeObject.ContainsKey("id")) | ||
this.name = outcomeObject["id"] as string; | ||
|
||
// timestamp | ||
if (outcomeObject.ContainsKey("timestamp")) | ||
this.timestamp = (long) outcomeObject["timestamp"]; | ||
|
||
// weight | ||
if (outcomeObject.ContainsKey("weight")) { | ||
if (outcomeObject["weight"] is Int64) | ||
this.weight = (Int64) outcomeObject["weight"]; | ||
if (outcomeObject["weight"] is Double) | ||
this.weight = (Double) outcomeObject["weight"]; | ||
} | ||
|
||
} | ||
|
||
public static OSSession SessionFromString(string session) | ||
{ | ||
session = session.ToLower(); | ||
if (session == "direct") | ||
return OSSession.DIRECT; | ||
if (session == "indirect") | ||
return OSSession.INDIRECT; | ||
if (session == "unattributed") | ||
return OSSession.UNATTRIBUTED; | ||
|
||
return OSSession.DISABLED; | ||
} | ||
} | ||
} |
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
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
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
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
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
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,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Com.OneSignal.Abstractions; | ||
using Com.OneSignal.Android; | ||
|
||
namespace Com.OneSignal | ||
{ | ||
public class SendOutcomeEventSuccessHandler : Java.Lang.Object, Android.OneSignal.IOutcomeCallback | ||
{ | ||
|
||
readonly SendOutcomeEventSuccess _sendOutcomeEventSuccess; | ||
|
||
public SendOutcomeEventSuccessHandler(SendOutcomeEventSuccess sendOutcomeEventSuccess) => _sendOutcomeEventSuccess = sendOutcomeEventSuccess; | ||
|
||
public void OnSuccess(OutcomeEvent outcome) | ||
{ | ||
OSOutcomeEvent outcomeEvent = OSSendOutcomeEventSuccessToNative(outcome); | ||
_sendOutcomeEventSuccess(outcomeEvent); | ||
} | ||
|
||
private static OSOutcomeEvent OSSendOutcomeEventSuccessToNative(OutcomeEvent outcome) | ||
{ | ||
if (outcome == null) | ||
return new OSOutcomeEvent(); | ||
|
||
Dictionary<string, object> outcomeObject = Json.Deserialize(outcome.ToJSONObject().ToString()) as Dictionary<string, object>; | ||
|
||
OSOutcomeEvent outcomeEvent = new OSOutcomeEvent(outcomeObject); | ||
|
||
return outcomeEvent; | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.