Skip to content

Commit

Permalink
Merge pull request #53 from AppsFlyerSDK/releases/6.x.x/6.1.x/6.1.3
Browse files Browse the repository at this point in the history
Releases/6.x.x/6.1.x/6.1.3
  • Loading branch information
wesfieldj authored Jan 6, 2021
2 parents 4c357a5 + 395dc8a commit 47c141b
Show file tree
Hide file tree
Showing 21 changed files with 544 additions and 13 deletions.
67 changes: 66 additions & 1 deletion Assets/AppsFlyer/AppsFlyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ namespace AppsFlyerSDK
public class AppsFlyer : MonoBehaviour
{

public static readonly string kAppsFlyerPluginVersion = "6.1.0";
public static readonly string kAppsFlyerPluginVersion = "6.1.3";
public static string CallBackObjectName = null;
private static EventHandler onRequestResponse;
private static EventHandler onInAppResponse;
private static EventHandler onDeepLinkReceived;


/// <summary>
Expand Down Expand Up @@ -483,6 +484,40 @@ public static void generateUserInviteLink(Dictionary<string, string> parameters,
AppsFlyerAndroid.generateUserInviteLink(parameters, gameObject);
#else

#endif
}


/// <summary>
/// Use this method if you’re integrating your app with push providers
/// that don’t use the default push notification JSON schema the SDK expects.
/// See docs for more info.
/// </summary>
/// <param name="paths">array of nested json path</param>
public static void addPushNotificationDeepLinkPath(params string[] paths)
{
#if UNITY_IOS && !UNITY_EDITOR
AppsFlyeriOS.addPushNotificationDeepLinkPath(paths);
#elif UNITY_ANDROID && !UNITY_EDITOR
AppsFlyerAndroid.addPushNotificationDeepLinkPath(paths);
#else

#endif
}

/// <summary>
/// Subscribe for unified deeplink API.
/// This is called automatically from OnDeepLinkReceived.
/// CallBackObjectName is set in the init method.
/// </summary>
public static void subscribeForDeepLink()
{
#if UNITY_IOS && !UNITY_EDITOR
AppsFlyeriOS.subscribeForDeepLink(CallBackObjectName);
#elif UNITY_ANDROID && !UNITY_EDITOR
AppsFlyerAndroid.subscribeForDeepLink(CallBackObjectName);
#else

#endif
}

Expand Down Expand Up @@ -516,6 +551,22 @@ public static event EventHandler OnInAppResponse
}
}

/// <summary>
/// Unified DeepLink Event
/// </summary>
public static event EventHandler OnDeepLinkReceived
{
add
{
onDeepLinkReceived += value;
subscribeForDeepLink();
}
remove
{
onDeepLinkReceived -= value;
}
}

/// <summary>
/// Used to accept start callback from UnitySendMessage on native side.
/// </summary>
Expand All @@ -538,6 +589,20 @@ public void requestResponseReceived(string response)
}
}

/// <summary>
/// Used to accept deeplink callback from UnitySendMessage on native side.
/// </summary>
public void onDeepLinking(string response)
{

DeepLinkEventsArgs args = new DeepLinkEventsArgs(response);

if (onDeepLinkReceived != null)
{
onDeepLinkReceived.Invoke(null, args);
}
}

private static AppsFlyerRequestEventArgs parseRequestCallback(string response)
{
int responseCode = 0;
Expand Down
22 changes: 22 additions & 0 deletions Assets/AppsFlyer/AppsFlyerAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,28 @@ public static void handlePushNotifications(){
#endif
}

/// <summary>
/// Use this method if you’re integrating your app with push providers
/// that don’t use the default push notification JSON schema the SDK expects.
/// See docs for more info.
/// </summary>
/// <param name="paths">array of nested json path</param>
public static void addPushNotificationDeepLinkPath(params string[] paths)
{
#if !UNITY_EDITOR
appsFlyerAndroid.CallStatic("addPushNotificationDeepLinkPath", (object)paths);
#endif
}

/// <summary>
/// subscribe to unified deep link callbacks
/// </summary>
public static void subscribeForDeepLink(string objectName){
#if !UNITY_EDITOR
appsFlyerAndroid.CallStatic("subscribeForDeepLink", objectName);
#endif
}

/// <summary>
/// Internal Helper Method.
/// </summary>
Expand Down
183 changes: 182 additions & 1 deletion Assets/AppsFlyer/AppsFlyerEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;

namespace AppsFlyerSDK
{
Expand Down Expand Up @@ -31,4 +32,184 @@ public AppsFlyerRequestEventArgs(int code, string description)
public int statusCode { get; }
public string errorDescription { get; }
}
}

/// <summary>
/// Event args for OnDeepLinkReceived.
/// Used to handle deep linking results.
/// </summary>
public class DeepLinkEventsArgs : EventArgs
{

/// <summary>
/// DeepLink dictionary to get additional parameters
/// </summary>
public Dictionary<string, object> deepLink;

/// <summary>
/// DeepLink status: FOUND, NOT_FOUND, ERROR
/// </summary>
public DeepLinkStatus status { get; }

/// <summary>
/// DeepLink error: TIMEOUT, NETWORK, HTTP_STATUS_CODE, UNEXPECTED
/// </summary>
public DeepLinkError error { get; }

public string getMatchType()
{
return getDeepLinkParameter("match_type");
}

public string getDeepLinkValue()
{
return getDeepLinkParameter("deep_link_value");
}

public string getClickHttpReferrer()
{
return getDeepLinkParameter("click_http_referrer");
}

public string getMediaSource()
{
return getDeepLinkParameter("media_source");
}

public string getCampaign()
{
return getDeepLinkParameter("campaign");
}

public string getCampaignId()
{
return getDeepLinkParameter("campaign_id");
}

public string getAfSub1()
{
return getDeepLinkParameter("af_sub1");
}

public string getAfSub2()
{
return getDeepLinkParameter("af_sub2");
}

public string getAfSub3()
{
return getDeepLinkParameter("af_sub3");
}

public string getAfSub4()
{
return getDeepLinkParameter("af_sub4");
}

public string getAfSub5()
{
return getDeepLinkParameter("af_sub5");
}

public bool isDeferred()
{
if (deepLink != null && deepLink.ContainsKey("is_deferred"))
{
try
{
return (bool)deepLink["is_deferred"];
}
catch (Exception e)
{
AppsFlyer.AFLog("DeepLinkEventsArgs.isDeferred", String.Format("{0} Exception caught.", e));
}
}

return false;
}

public Dictionary<string, object> getDeepLinkDictionary()
{
return deepLink;
}

public DeepLinkEventsArgs(string str)
{
try
{
Dictionary<string, object> dictionary = AppsFlyer.CallbackStringToDictionary(str);

string status = "";
string error = "";
Dictionary<string, object> deepLink;

if (dictionary.ContainsKey("status") && dictionary["status"] != null)
{
status = dictionary["status"].ToString();
}

if (dictionary.ContainsKey("error") && dictionary["error"] != null)
{
error = dictionary["error"].ToString();
}

if (dictionary.ContainsKey("deepLink") && dictionary["deepLink"] != null)
{
this.deepLink = AppsFlyer.CallbackStringToDictionary(dictionary["deepLink"].ToString());
}

switch (status)
{
case "FOUND":
this.status = DeepLinkStatus.FOUND;
break;
case "NOT_FOUND":
this.status = DeepLinkStatus.NOT_FOUND;
break;
default:
this.status = DeepLinkStatus.ERROR;
break;
}

switch (error)
{
case "TIMEOUT":
this.error = DeepLinkError.TIMEOUT;
break;
case "NETWORK":
this.error = DeepLinkError.NETWORK;
break;
case "HTTP_STATUS_CODE":
this.error = DeepLinkError.HTTP_STATUS_CODE;
break;
default:
this.error = DeepLinkError.UNEXPECTED;
break;
}

}
catch (Exception e)
{
AppsFlyer.AFLog("DeepLinkEventsArgs.parseDeepLink", String.Format("{0} Exception caught.", e));
}
}

private string getDeepLinkParameter(string name)
{
if (deepLink != null && deepLink.ContainsKey(name) && deepLink[name] != null)
{
return deepLink[name].ToString();
}

return null;
}

}

public enum DeepLinkStatus {
FOUND, NOT_FOUND, ERROR
}

public enum DeepLinkError {
TIMEOUT, NETWORK, HTTP_STATUS_CODE, UNEXPECTED
}
}
27 changes: 27 additions & 0 deletions Assets/AppsFlyer/AppsFlyeriOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,27 @@ public static void disableSKAdNetwork(bool isDisabled)
#endif
}

/// <summary>
/// Use this method if you’re integrating your app with push providers
/// that don’t use the default push notification JSON schema the SDK expects.
/// See docs for more info.
/// </summary>
/// <param name="paths">array of nested json path</param>
public static void addPushNotificationDeepLinkPath(params string[] paths)
{
#if !UNITY_EDITOR
_addPushNotificationDeepLinkPath(paths.Length, paths);
#endif
}

/// <summary>
/// subscribe to unified deep link callbacks
/// </summary>
public static void subscribeForDeepLink(string objectName){
#if !UNITY_EDITOR
_subscribeForDeepLink(objectName);
#endif
}

/*
* AppsFlyer ios method mapping
Expand Down Expand Up @@ -615,6 +636,12 @@ public static void disableSKAdNetwork(bool isDisabled)
[DllImport("__Internal")]
private static extern void _disableSKAdNetwork(bool isDisabled);

[DllImport("__Internal")]
private static extern void _addPushNotificationDeepLinkPath(int length, params string[] paths);

[DllImport("__Internal")]
private static extern void _subscribeForDeepLink(string objectName);

}

#endif
Expand Down
6 changes: 3 additions & 3 deletions Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<dependencies>

<androidPackages>
<androidPackage spec="com.appsflyer:af-android-sdk:6.1.0">
<androidPackage spec="com.appsflyer:af-android-sdk:6.1.3">
</androidPackage>
<androidPackage spec="com.appsflyer:unity-wrapper:6.1.1">
<androidPackage spec="com.appsflyer:unity-wrapper:6.1.3">
</androidPackage>
<androidPackage spec="com.android.installreferrer:installreferrer:2.1">
</androidPackage>
</androidPackages>

<iosPods>
<iosPod name="AppsFlyerFramework" version="6.1.1" minTargetSdk="8.0">
<iosPod name="AppsFlyerFramework" version="6.1.3" minTargetSdk="8.0">
</iosPod>
</iosPods>

Expand Down
Loading

0 comments on commit 47c141b

Please sign in to comment.