Skip to content

Commit

Permalink
6.3.0
Browse files Browse the repository at this point in the history
6.3.0
  • Loading branch information
amit-kremer93 authored May 27, 2021
2 parents a5100fe + eb34a11 commit 7495e1b
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 104 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ You can read more [here](https://support.appsflyer.com/hc/en-us/articles/2070320

### <a id="plugin-build-for"> This plugin is built for

- iOS AppsFlyerSDK **v6.2.6**
- Android AppsFlyerSDK **v6.2.0**
- iOS AppsFlyerSDK **v6.3.0**
- Android AppsFlyerSDK **v6.3.0**

### <a id="breakingChanges"> ❗v6 Breaking Changes

Expand Down
7 changes: 7 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Release Notes
### 6.3.0
Release date: *2021-May-27*

**Overview and Highlights:**
- Cordova > update to native sdk 6.3.0
- Cordova (Ios) >> deep linking listeners

### 6.2.60
Release date: *2021-April-27*

Expand Down
4 changes: 2 additions & 2 deletions docs/Guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ In both cases, you need to add this code before the `@end` tag:<br>
// Open URI-scheme for iOS 8 and below
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation {
// version >= 6.2.30
[[AppsFlyerAttribution shared] handleOpenURL:url sourceApplication:sourceApplication annotation:annotation];
[[AppsFlyerAttribution shared] handleOpenUrl:url sourceApplication:sourceApplication annotation:annotation];
// version < 6.2.30
[[AppsFlyerLib shared] handleOpenURL:url sourceApplication:sourceApplication withAnnotation:annotation];
[[AppsFlyerLib shared] handleOpenUrl:url sourceApplication:sourceApplication withAnnotation:annotation];
return YES;
}
// Open Universal Links
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-appsflyer-sdk",
"version": "6.2.60",
"version": "6.3.0",
"description": "Cordova AppsFlyer SDK Plugin",
"cordova": {
"id": "cordova-plugin-appsflyer-sdk",
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-appsflyer-sdk"
version="6.2.60">
version="6.3.0">
<name>AppsFlyer</name>
<description>Cordova Plugin AppsFlyer</description>
<license>Apache 2.0</license>
Expand Down Expand Up @@ -92,7 +92,7 @@
<config>
</config>
<pods use-frameworks="true">
<pod name="AppsFlyerFramework" spec="6.2.6"/>
<pod name="AppsFlyerFramework" spec="6.3.0"/>
</pods>
</podspec>
</platform>
Expand Down
48 changes: 11 additions & 37 deletions src/android/com/appsflyer/cordova/plugin/AppsFlyerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import android.support.annotation.NonNull;
import android.util.Log;

import static com.appsflyer.cordova.plugin.AppsFlyerConstants.*;
Expand All @@ -44,10 +44,8 @@ public class AppsFlyerPlugin extends CordovaPlugin {
private CallbackContext mConversionListener = null;
private CallbackContext mAttributionDataListener = null;
private CallbackContext mDeepLinkListener = null;
// private Map<String, String> mAttributionData = null;
private CallbackContext mInviteListener = null;
private Uri intentURI = null;
// private Uri newIntentURI = null;
private Activity c;

@Override
Expand Down Expand Up @@ -122,7 +120,7 @@ public boolean execute(final String action, JSONArray args, CallbackContext call
return setHost(args);
} else if ("addPushNotificationDeepLinkPath".equals(action)) {
return addPushNotificationDeepLinkPath(args);
}else if ("setResolveDeepLinkURLs".equals(action)) {
} else if ("setResolveDeepLinkURLs".equals(action)) {
return setResolveDeepLinkURLs(args);
}

Expand All @@ -142,28 +140,6 @@ private boolean registerDeepLink(CallbackContext callbackContext) {
return true;
}


/**
* check if the app was launched from deep link after init()
*/
private void trackAppLaunch() {
c = this.cordova.getActivity();
intentURI = cordova.getActivity().getIntent().getData();
if (intentURI != null) {
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
try {
AppsFlyerLib.getInstance().performOnAppAttribution(cordova.getContext(), new URI(intentURI.toString()));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
});
}
AppsFlyerLib.getInstance().logEvent(c, null, null);
}

/**
* Get the deeplink data
*
Expand Down Expand Up @@ -194,6 +170,7 @@ private boolean initSdk(final JSONArray args, final CallbackContext callbackCont

AppsFlyerProperties.getInstance().set(AppsFlyerProperties.LAUNCH_PROTECT_ENABLED, false);
AppsFlyerLib instance = AppsFlyerLib.getInstance();
c = this.cordova.getActivity();

try {
final JSONObject options = args.getJSONObject(0);
Expand Down Expand Up @@ -234,14 +211,10 @@ private boolean initSdk(final JSONArray args, final CallbackContext callbackCont
} else {
//callbackContext.success(SUCCESS);
}

instance.init(devKey, gcdListener, cordova.getActivity());

trackAppLaunch();


if (mConversionListener == null) {
instance.start(c.getApplication(), devKey, new AppsFlyerRequestListener() {
instance.start(c, devKey, new AppsFlyerRequestListener() {
@Override
public void onSuccess() {
callbackContext.success(SUCCESS);
Expand All @@ -253,11 +226,10 @@ public void onError(int i, String s) {
}
});
} else {
instance.start(c.getApplicationContext());
instance.start(c);
}


instance.start(c.getApplicationContext());
instance.start(c);

if (gcdListener != null) {
sendPluginNoResult(callbackContext);
Expand Down Expand Up @@ -290,7 +262,10 @@ public void onDeepLinking(@NonNull DeepLinkResult deepLinkResult) {
deepLinkObj.put("data", dlError.toString());
} else {
deepLinkObj.put("status", AF_SUCCESS);
deepLinkObj.put("data", deepLinkResult.getDeepLink().toString());
if (deepLinkResult.getStatus() == DeepLinkResult.Status.FOUND) {
deepLinkObj.put("data", deepLinkResult.getDeepLink().getClickEvent());
deepLinkObj.put("isDeferred", deepLinkResult.getDeepLink().isDeferred());
}
}
sendEvent(deepLinkObj);
} catch (Exception e) {
Expand Down Expand Up @@ -395,9 +370,8 @@ private void sendEvent(JSONObject params) {
|| params.optString("type") == AF_ON_INSTALL_CONVERSION_FAILURE)
&& mConversionListener != null) {
PluginResult result = new PluginResult(PluginResult.Status.OK, jsonStr);
result.setKeepCallback(false);
result.setKeepCallback(true);
mConversionListener.sendPluginResult(result);
mConversionListener = null;
} else if (
params.optString("type") == AF_DEEP_LINK
&& mDeepLinkListener != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/android/cordovaAF.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ repositories {

dependencies {
implementation 'com.android.installreferrer:installreferrer:2.1'
implementation 'com.appsflyer:af-android-sdk:6.2.0@aar'
implementation 'com.appsflyer:af-android-sdk:6.3.0@aar'
implementation 'com.android.support:support-annotations:28.0.0'
}
20 changes: 0 additions & 20 deletions src/ios/AppsFlyerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -825,23 +825,3 @@ - (void)disableSKAD:(CDVInvokedUrlCommand *)command
}

@end


// Universal Links Support - AppDelegate interface:
@interface AppDelegate (AppsFlyerPlugin)

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler;

@end

// Universal Links Support - AppDelegate implementation:
@implementation AppDelegate (AppsFlyerPlugin)

// Depricated: swizzeled method see AppsFlyerX+AppController.m
// - (BOOL) application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *_Nullable))restorationHandler
// {
// [[AppsFlyerLib shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
// return YES;
// }

@end
7 changes: 6 additions & 1 deletion src/ios/AppsFlyerX+AppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@

@interface AppDelegate (AppsFlyerX)

@end
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options;

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler;

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;

@end
48 changes: 10 additions & 38 deletions src/ios/AppsFlyerX+AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,22 @@
#import <Foundation/Foundation.h>
#import "AppsFlyerX+AppController.h"
#import <objc/runtime.h>
#import "AppsFlyerLib.h"
#import "AppsFlyerAttribution.h"

@implementation AppDelegate (AppsFlyerX)

static BOOL isOriginalImpementationExist;

+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];

SEL originalSelector = @selector(application: continueUserActivity: restorationHandler:);
SEL swizzledSelector = @selector(x_application: continueUserActivity: restorationHandler:);

Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);

isOriginalImpementationExist = [class instancesRespondToSelector:originalSelector];

BOOL didAddMethod =
class_addMethod(class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));

if (didAddMethod) {
class_replaceMethod(class,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
[[AppsFlyerAttribution shared] handleOpenUrl:url options:options];
return YES;
}

#pragma mark - Method Swizzling
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler{
[[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
return YES;
}

- (BOOL)x_application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {
[[AppsFlyerLib shared] continueUserActivity:userActivity restorationHandler:restorationHandler];

if (isOriginalImpementationExist) {
[self x_application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
[[AppsFlyerAttribution shared] handleOpenUrl:url sourceApplication:sourceApplication annotation:annotation];
return YES;
}

Expand Down

0 comments on commit 7495e1b

Please sign in to comment.