-
Notifications
You must be signed in to change notification settings - Fork 11
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 #13 from AppsFlyerSDK/dev/RD-51316/strict-mode
Dev/rd 51316/strict mode
- Loading branch information
Showing
35 changed files
with
3,662 additions
and
45 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
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,36 @@ | ||
// | ||
// AFSDKDeeplink.h | ||
// AppsFlyerLib | ||
// | ||
// Created by Andrii Hahan on 20.08.2020. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
NS_SWIFT_NAME(DeepLink) | ||
@interface AppsFlyerDeepLink : NSObject | ||
|
||
- (nonnull instancetype)init NS_UNAVAILABLE; | ||
+ (nonnull instancetype)new NS_UNAVAILABLE; | ||
|
||
@property (readonly, nonnull) NSDictionary<NSString *, id> *clickEvent; | ||
@property (readonly, nullable) NSString *deeplinkValue; | ||
@property (readonly, nullable) NSString *matchType; | ||
@property (readonly, nullable) NSString *clickHTTPReferrer; | ||
@property (readonly, nullable) NSString *mediaSource; | ||
@property (readonly, nullable) NSString *campaign; | ||
@property (readonly, nullable) NSString *campaignId; | ||
@property (readonly, nullable) NSString *afSub1; | ||
@property (readonly, nullable) NSString *afSub2; | ||
@property (readonly, nullable) NSString *afSub3; | ||
@property (readonly, nullable) NSString *afSub4; | ||
@property (readonly, nullable) NSString *afSub5; | ||
@property (readonly) BOOL isDeferred; | ||
|
||
- (NSString *)toString; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
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,29 @@ | ||
// | ||
// AFSDKDeeplinkResult.h | ||
// AppsFlyerLib | ||
// | ||
// Created by Andrii Hahan on 20.08.2020. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@class AppsFlyerDeepLink; | ||
|
||
typedef NS_CLOSED_ENUM(NSUInteger, AFSDKDeepLinkResultStatus) { | ||
AFSDKDeepLinkResultStatusNotFound, | ||
AFSDKDeepLinkResultStatusFound, | ||
AFSDKDeepLinkResultStatusFailure, | ||
} NS_SWIFT_NAME(DeepLinkResultStatus); | ||
|
||
NS_SWIFT_NAME(DeepLinkResult) | ||
@interface AppsFlyerDeepLinkResult : NSObject | ||
|
||
- (nonnull instancetype)init NS_UNAVAILABLE; | ||
+ (nonnull instancetype)new NS_UNAVAILABLE; | ||
|
||
@property(readonly) AFSDKDeepLinkResultStatus status; | ||
|
||
@property(readonly, nullable) AppsFlyerDeepLink *deepLink; | ||
@property(readonly, nullable) NSError *error; | ||
|
||
@end |
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
Binary file not shown.
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,144 @@ | ||
// | ||
// Created by Maxim Shoustin on 10/9/17. | ||
// | ||
|
||
#include <string> | ||
#include "AppsFlyerProxyX.h" | ||
#include <typeinfo> | ||
#include "../../cocos2d/cocos/platform/CCPlatformMacros.h" | ||
|
||
|
||
|
||
|
||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) | ||
|
||
cocos2d::ValueMap getMapForCallback(JNIEnv *env, jobject attributionObject); | ||
|
||
void setAttributionCallbackOnConversionDataReceived( | ||
void (*callbackMethod)(cocos2d::ValueMap installData)) { | ||
if (NULL == attributionCallbackOnConversionDataReceived) { | ||
attributionCallbackOnConversionDataReceived = callbackMethod; | ||
} | ||
} | ||
|
||
void setAttributionCallbackOnAppOpenAttribution( | ||
void (*callbackMethod)(cocos2d::ValueMap attributionData)) { | ||
if (NULL == attributionCallbackOnAppOpenAttribution) { | ||
attributionCallbackOnAppOpenAttribution = callbackMethod; | ||
} | ||
} | ||
|
||
void setAttributionCallbackOnConversionDataRequestFailure( | ||
void (*callbackMethod)(cocos2d::ValueMap error)) { | ||
if (NULL == attributionCallbackOnConversionDataRequestFailure) { | ||
attributionCallbackOnConversionDataRequestFailure = callbackMethod; | ||
} | ||
} | ||
|
||
void setAttributionCallbackOnAppOpenAttributionFailure( | ||
void (*callbackMethod)(cocos2d::ValueMap error)) { | ||
if (NULL == attributionCallbackOnAppOpenAttributionFailure) { | ||
attributionCallbackOnAppOpenAttributionFailure = callbackMethod; | ||
} | ||
} | ||
|
||
/** | ||
* TODO: handle other types of data | ||
* */ | ||
JNIEXPORT void JNICALL Java_com_appsflyer_AppsFlyer2dXConversionCallback_onInstallConversionDataLoadedNative | ||
(JNIEnv *env, jobject obj, jobject attributionObject) { | ||
|
||
if (NULL == attributionCallbackOnConversionDataReceived) { | ||
return; | ||
} | ||
attributionCallbackOnConversionDataReceived(getMapForCallback(env, attributionObject)); | ||
} | ||
|
||
|
||
JNIEXPORT void JNICALL Java_com_appsflyer_AppsFlyer2dXConversionCallback_onAppOpenAttributionNative | ||
(JNIEnv *env, jobject obj, jobject attributionObject){ | ||
CCLOG("%s","Java_com_appsflyer_AppsFlyer2dXConversionCallback_onAppOpenAttributionNative is called"); | ||
|
||
if (NULL == attributionCallbackOnAppOpenAttribution) { | ||
return; | ||
} | ||
attributionCallbackOnAppOpenAttribution(getMapForCallback(env, attributionObject)); | ||
|
||
} | ||
|
||
JNIEXPORT void JNICALL Java_com_appsflyer_AppsFlyer2dXConversionCallback_onAttributionFailureNative | ||
(JNIEnv *env, jobject obj, jobject stringError){ | ||
|
||
CCLOG("%s","Java_com_appsflyer_AppsFlyer2dXConversionCallback_onInstallConversionFailureNative is called"); | ||
|
||
if (NULL == attributionCallbackOnAppOpenAttributionFailure) { | ||
return; | ||
} | ||
attributionCallbackOnAppOpenAttributionFailure(getMapForCallback(env,stringError)); | ||
} | ||
|
||
JNIEXPORT void JNICALL Java_com_appsflyer_AppsFlyer2dXConversionCallback_onInstallConversionFailureNative | ||
(JNIEnv *env, jobject obj, jobject stringError) { | ||
|
||
CCLOG("%s","Java_com_appsflyer_AppsFlyer2dXConversionCallback_onInstallConversionFailureNative is called"); | ||
|
||
if (NULL == attributionCallbackOnConversionDataRequestFailure) { | ||
return; | ||
} | ||
|
||
attributionCallbackOnConversionDataRequestFailure(getMapForCallback(env,stringError)); | ||
} | ||
|
||
|
||
cocos2d::ValueMap getMapForCallback(JNIEnv *env, jobject attributionObject) { | ||
jclass clsHashMap = env->GetObjectClass(attributionObject); | ||
cocos2d::ValueMap map; | ||
jmethodID midKeySet = env->GetMethodID(clsHashMap, "keySet", "()Ljava/util/Set;"); | ||
|
||
if (midKeySet == NULL) { | ||
return map; /* method not found */ | ||
} | ||
|
||
jobject objKeySet = env->CallObjectMethod(attributionObject, midKeySet); | ||
|
||
//javap -s -p java.util.Set | grep -A 1 toArray | ||
jclass clsSet = env->GetObjectClass(objKeySet); | ||
|
||
jmethodID midToArray = env->GetMethodID(clsSet, "toArray", "()[Ljava/lang/Object;"); | ||
|
||
if (midToArray == NULL) { | ||
return map; /* method not found */ | ||
} | ||
|
||
jobjectArray arrayOfKeys = (jobjectArray) env->CallObjectMethod(objKeySet, midToArray); | ||
int arraySize = env->GetArrayLength(arrayOfKeys); | ||
jclass jBooleanClass = env->FindClass("java/lang/Boolean"); | ||
jclass jStringClass = env->FindClass("java/lang/String"); | ||
|
||
for (int i=0; i < arraySize; ++i){ | ||
jstring objKey = (jstring) env->GetObjectArrayElement(arrayOfKeys, i); | ||
const char* c_string_key = env->GetStringUTFChars(objKey, 0); | ||
jmethodID midGet = env->GetMethodID(clsHashMap, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); | ||
jobject objValue = env->CallObjectMethod(attributionObject, midGet, objKey); | ||
if (objValue == NULL) { | ||
map[std::string(c_string_key)] = cocos2d::Value::Null; | ||
} | ||
else if (env->IsInstanceOf(objValue, jBooleanClass)){ | ||
jmethodID booleanValueMID = env->GetMethodID(jBooleanClass, "booleanValue", "()Z"); | ||
bool booleanValue = (bool) env->CallBooleanMethod(objValue, booleanValueMID); | ||
map[std::string(c_string_key)] = booleanValue; | ||
} else if (env->IsInstanceOf(objValue, jStringClass)){ | ||
jstring objString = (jstring)objValue; | ||
const char *c_string_value = env->GetStringUTFChars(objString, 0); | ||
map[std::string(c_string_key)] = c_string_value; | ||
} | ||
|
||
env->DeleteLocalRef(objValue); | ||
} | ||
|
||
return map; | ||
} | ||
|
||
|
||
#endif | ||
|
Oops, something went wrong.