11using System ;
2+ using System . Collections . Generic ;
23
34namespace 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+ }
0 commit comments