Skip to content

Commit 47c141b

Browse files
authored
Merge pull request #53 from AppsFlyerSDK/releases/6.x.x/6.1.x/6.1.3
Releases/6.x.x/6.1.x/6.1.3
2 parents 4c357a5 + 395dc8a commit 47c141b

21 files changed

+544
-13
lines changed

Assets/AppsFlyer/AppsFlyer.cs

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ namespace AppsFlyerSDK
77
public class AppsFlyer : MonoBehaviour
88
{
99

10-
public static readonly string kAppsFlyerPluginVersion = "6.1.0";
10+
public static readonly string kAppsFlyerPluginVersion = "6.1.3";
1111
public static string CallBackObjectName = null;
1212
private static EventHandler onRequestResponse;
1313
private static EventHandler onInAppResponse;
14+
private static EventHandler onDeepLinkReceived;
1415

1516

1617
/// <summary>
@@ -483,6 +484,40 @@ public static void generateUserInviteLink(Dictionary<string, string> parameters,
483484
AppsFlyerAndroid.generateUserInviteLink(parameters, gameObject);
484485
#else
485486

487+
#endif
488+
}
489+
490+
491+
/// <summary>
492+
/// Use this method if you’re integrating your app with push providers
493+
/// that don’t use the default push notification JSON schema the SDK expects.
494+
/// See docs for more info.
495+
/// </summary>
496+
/// <param name="paths">array of nested json path</param>
497+
public static void addPushNotificationDeepLinkPath(params string[] paths)
498+
{
499+
#if UNITY_IOS && !UNITY_EDITOR
500+
AppsFlyeriOS.addPushNotificationDeepLinkPath(paths);
501+
#elif UNITY_ANDROID && !UNITY_EDITOR
502+
AppsFlyerAndroid.addPushNotificationDeepLinkPath(paths);
503+
#else
504+
505+
#endif
506+
}
507+
508+
/// <summary>
509+
/// Subscribe for unified deeplink API.
510+
/// This is called automatically from OnDeepLinkReceived.
511+
/// CallBackObjectName is set in the init method.
512+
/// </summary>
513+
public static void subscribeForDeepLink()
514+
{
515+
#if UNITY_IOS && !UNITY_EDITOR
516+
AppsFlyeriOS.subscribeForDeepLink(CallBackObjectName);
517+
#elif UNITY_ANDROID && !UNITY_EDITOR
518+
AppsFlyerAndroid.subscribeForDeepLink(CallBackObjectName);
519+
#else
520+
486521
#endif
487522
}
488523

@@ -516,6 +551,22 @@ public static event EventHandler OnInAppResponse
516551
}
517552
}
518553

554+
/// <summary>
555+
/// Unified DeepLink Event
556+
/// </summary>
557+
public static event EventHandler OnDeepLinkReceived
558+
{
559+
add
560+
{
561+
onDeepLinkReceived += value;
562+
subscribeForDeepLink();
563+
}
564+
remove
565+
{
566+
onDeepLinkReceived -= value;
567+
}
568+
}
569+
519570
/// <summary>
520571
/// Used to accept start callback from UnitySendMessage on native side.
521572
/// </summary>
@@ -538,6 +589,20 @@ public void requestResponseReceived(string response)
538589
}
539590
}
540591

592+
/// <summary>
593+
/// Used to accept deeplink callback from UnitySendMessage on native side.
594+
/// </summary>
595+
public void onDeepLinking(string response)
596+
{
597+
598+
DeepLinkEventsArgs args = new DeepLinkEventsArgs(response);
599+
600+
if (onDeepLinkReceived != null)
601+
{
602+
onDeepLinkReceived.Invoke(null, args);
603+
}
604+
}
605+
541606
private static AppsFlyerRequestEventArgs parseRequestCallback(string response)
542607
{
543608
int responseCode = 0;

Assets/AppsFlyer/AppsFlyerAndroid.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,28 @@ public static void handlePushNotifications(){
620620
#endif
621621
}
622622

623+
/// <summary>
624+
/// Use this method if you’re integrating your app with push providers
625+
/// that don’t use the default push notification JSON schema the SDK expects.
626+
/// See docs for more info.
627+
/// </summary>
628+
/// <param name="paths">array of nested json path</param>
629+
public static void addPushNotificationDeepLinkPath(params string[] paths)
630+
{
631+
#if !UNITY_EDITOR
632+
appsFlyerAndroid.CallStatic("addPushNotificationDeepLinkPath", (object)paths);
633+
#endif
634+
}
635+
636+
/// <summary>
637+
/// subscribe to unified deep link callbacks
638+
/// </summary>
639+
public static void subscribeForDeepLink(string objectName){
640+
#if !UNITY_EDITOR
641+
appsFlyerAndroid.CallStatic("subscribeForDeepLink", objectName);
642+
#endif
643+
}
644+
623645
/// <summary>
624646
/// Internal Helper Method.
625647
/// </summary>

Assets/AppsFlyer/AppsFlyerEventArgs.cs

Lines changed: 182 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23

34
namespace AppsFlyerSDK
45
{
@@ -31,4 +32,184 @@ public AppsFlyerRequestEventArgs(int code, string description)
3132
public int statusCode { get; }
3233
public string errorDescription { get; }
3334
}
34-
}
35+
36+
/// <summary>
37+
/// Event args for OnDeepLinkReceived.
38+
/// Used to handle deep linking results.
39+
/// </summary>
40+
public class DeepLinkEventsArgs : EventArgs
41+
{
42+
43+
/// <summary>
44+
/// DeepLink dictionary to get additional parameters
45+
/// </summary>
46+
public Dictionary<string, object> deepLink;
47+
48+
/// <summary>
49+
/// DeepLink status: FOUND, NOT_FOUND, ERROR
50+
/// </summary>
51+
public DeepLinkStatus status { get; }
52+
53+
/// <summary>
54+
/// DeepLink error: TIMEOUT, NETWORK, HTTP_STATUS_CODE, UNEXPECTED
55+
/// </summary>
56+
public DeepLinkError error { get; }
57+
58+
public string getMatchType()
59+
{
60+
return getDeepLinkParameter("match_type");
61+
}
62+
63+
public string getDeepLinkValue()
64+
{
65+
return getDeepLinkParameter("deep_link_value");
66+
}
67+
68+
public string getClickHttpReferrer()
69+
{
70+
return getDeepLinkParameter("click_http_referrer");
71+
}
72+
73+
public string getMediaSource()
74+
{
75+
return getDeepLinkParameter("media_source");
76+
}
77+
78+
public string getCampaign()
79+
{
80+
return getDeepLinkParameter("campaign");
81+
}
82+
83+
public string getCampaignId()
84+
{
85+
return getDeepLinkParameter("campaign_id");
86+
}
87+
88+
public string getAfSub1()
89+
{
90+
return getDeepLinkParameter("af_sub1");
91+
}
92+
93+
public string getAfSub2()
94+
{
95+
return getDeepLinkParameter("af_sub2");
96+
}
97+
98+
public string getAfSub3()
99+
{
100+
return getDeepLinkParameter("af_sub3");
101+
}
102+
103+
public string getAfSub4()
104+
{
105+
return getDeepLinkParameter("af_sub4");
106+
}
107+
108+
public string getAfSub5()
109+
{
110+
return getDeepLinkParameter("af_sub5");
111+
}
112+
113+
public bool isDeferred()
114+
{
115+
if (deepLink != null && deepLink.ContainsKey("is_deferred"))
116+
{
117+
try
118+
{
119+
return (bool)deepLink["is_deferred"];
120+
}
121+
catch (Exception e)
122+
{
123+
AppsFlyer.AFLog("DeepLinkEventsArgs.isDeferred", String.Format("{0} Exception caught.", e));
124+
}
125+
}
126+
127+
return false;
128+
}
129+
130+
public Dictionary<string, object> getDeepLinkDictionary()
131+
{
132+
return deepLink;
133+
}
134+
135+
public DeepLinkEventsArgs(string str)
136+
{
137+
try
138+
{
139+
Dictionary<string, object> dictionary = AppsFlyer.CallbackStringToDictionary(str);
140+
141+
string status = "";
142+
string error = "";
143+
Dictionary<string, object> deepLink;
144+
145+
if (dictionary.ContainsKey("status") && dictionary["status"] != null)
146+
{
147+
status = dictionary["status"].ToString();
148+
}
149+
150+
if (dictionary.ContainsKey("error") && dictionary["error"] != null)
151+
{
152+
error = dictionary["error"].ToString();
153+
}
154+
155+
if (dictionary.ContainsKey("deepLink") && dictionary["deepLink"] != null)
156+
{
157+
this.deepLink = AppsFlyer.CallbackStringToDictionary(dictionary["deepLink"].ToString());
158+
}
159+
160+
switch (status)
161+
{
162+
case "FOUND":
163+
this.status = DeepLinkStatus.FOUND;
164+
break;
165+
case "NOT_FOUND":
166+
this.status = DeepLinkStatus.NOT_FOUND;
167+
break;
168+
default:
169+
this.status = DeepLinkStatus.ERROR;
170+
break;
171+
}
172+
173+
switch (error)
174+
{
175+
case "TIMEOUT":
176+
this.error = DeepLinkError.TIMEOUT;
177+
break;
178+
case "NETWORK":
179+
this.error = DeepLinkError.NETWORK;
180+
break;
181+
case "HTTP_STATUS_CODE":
182+
this.error = DeepLinkError.HTTP_STATUS_CODE;
183+
break;
184+
default:
185+
this.error = DeepLinkError.UNEXPECTED;
186+
break;
187+
}
188+
189+
}
190+
catch (Exception e)
191+
{
192+
AppsFlyer.AFLog("DeepLinkEventsArgs.parseDeepLink", String.Format("{0} Exception caught.", e));
193+
}
194+
}
195+
196+
private string getDeepLinkParameter(string name)
197+
{
198+
if (deepLink != null && deepLink.ContainsKey(name) && deepLink[name] != null)
199+
{
200+
return deepLink[name].ToString();
201+
}
202+
203+
return null;
204+
}
205+
206+
}
207+
208+
public enum DeepLinkStatus {
209+
FOUND, NOT_FOUND, ERROR
210+
}
211+
212+
public enum DeepLinkError {
213+
TIMEOUT, NETWORK, HTTP_STATUS_CODE, UNEXPECTED
214+
}
215+
}

Assets/AppsFlyer/AppsFlyeriOS.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,27 @@ public static void disableSKAdNetwork(bool isDisabled)
493493
#endif
494494
}
495495

496+
/// <summary>
497+
/// Use this method if you’re integrating your app with push providers
498+
/// that don’t use the default push notification JSON schema the SDK expects.
499+
/// See docs for more info.
500+
/// </summary>
501+
/// <param name="paths">array of nested json path</param>
502+
public static void addPushNotificationDeepLinkPath(params string[] paths)
503+
{
504+
#if !UNITY_EDITOR
505+
_addPushNotificationDeepLinkPath(paths.Length, paths);
506+
#endif
507+
}
508+
509+
/// <summary>
510+
/// subscribe to unified deep link callbacks
511+
/// </summary>
512+
public static void subscribeForDeepLink(string objectName){
513+
#if !UNITY_EDITOR
514+
_subscribeForDeepLink(objectName);
515+
#endif
516+
}
496517

497518
/*
498519
* AppsFlyer ios method mapping
@@ -615,6 +636,12 @@ public static void disableSKAdNetwork(bool isDisabled)
615636
[DllImport("__Internal")]
616637
private static extern void _disableSKAdNetwork(bool isDisabled);
617638

639+
[DllImport("__Internal")]
640+
private static extern void _addPushNotificationDeepLinkPath(int length, params string[] paths);
641+
642+
[DllImport("__Internal")]
643+
private static extern void _subscribeForDeepLink(string objectName);
644+
618645
}
619646

620647
#endif

Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
<dependencies>
33

44
<androidPackages>
5-
<androidPackage spec="com.appsflyer:af-android-sdk:6.1.0">
5+
<androidPackage spec="com.appsflyer:af-android-sdk:6.1.3">
66
</androidPackage>
7-
<androidPackage spec="com.appsflyer:unity-wrapper:6.1.1">
7+
<androidPackage spec="com.appsflyer:unity-wrapper:6.1.3">
88
</androidPackage>
99
<androidPackage spec="com.android.installreferrer:installreferrer:2.1">
1010
</androidPackage>
1111
</androidPackages>
1212

1313
<iosPods>
14-
<iosPod name="AppsFlyerFramework" version="6.1.1" minTargetSdk="8.0">
14+
<iosPod name="AppsFlyerFramework" version="6.1.3" minTargetSdk="8.0">
1515
</iosPod>
1616
</iosPods>
1717

0 commit comments

Comments
 (0)