Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ android {
}

dependencies {
compileOnly "com.apxor.androidx:apxor-android-sdk-core:3.0.4@aar"
compileOnly "com.apxor.androidx:apxor-android-sdk-qe:1.6.6@aar"
compileOnly "com.apxor.androidx:apxor-android-sdk-rtm:2.3.8@aar"
compileOnly "com.apxor.androidx:wysiwyg:1.4.9@aar"
// compileOnly "com.apxor.androidx:apxor-android-sdk-core:3.0.4@aar"
// compileOnly "com.apxor.androidx:apxor-android-sdk-qe:1.6.6@aar"
// compileOnly "com.apxor.androidx:apxor-android-sdk-rtm:2.3.8@aar"
// compileOnly "com.apxor.androidx:wysiwyg:1.4.9@aar"
implementation project(path: ':core')
implementation project(path: ':qe')
implementation project(path: ':rtm-x')
implementation project(path: ':surveys')
implementation project(path: ':wysiwyg')
}
59 changes: 59 additions & 0 deletions android/src/main/java/com/apxor/flutter/ApxorEmbedView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.apxor.flutter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.flutter.plugin.platform.PlatformView;
import java.util.Map;

import com.apxor.androidsdk.core.utils.Logger;
import com.apxor.androidsdk.plugins.realtimeui.ApxorWidget;

import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.JSONMessageCodec;
import io.flutter.plugin.common.BinaryMessenger;
import com.apxor.androidsdk.core.ce.ExecutionListener;

import org.json.JSONObject;

class ApxorEmbedView implements PlatformView {
private ApxorWidget apxorView;
private int tag = -1;
private BasicMessageChannel<Object> viewChannel;

ApxorEmbedView(@NonNull Context context, int id, @Nullable Map<String, Object> creationParams, final BinaryMessenger binaryMessenger) {
try {
tag = (int) creationParams.get("id");
viewChannel = new BasicMessageChannel<>(
binaryMessenger,
"plugins.flutter.io/apxor_view_"+this.tag,
JSONMessageCodec.INSTANCE
);
} catch (Exception e) {
Logger.debug("Apxor","Flutter value key is not valid "+e.getMessage());
}
apxorView = new ApxorWidget(context,tag,"flutter",new ExecutionListener() {
@Override
public void onAfterExecute(Object result, boolean hasError) {
Logger.debug("Apxor","Received dimensions from native "+result+""+hasError);
if(result != null && viewChannel != null) {
if(result instanceof JSONObject) {
viewChannel.send(result);
}
}
}
});
}

@Override
public View getView() {
return apxorView;
}

@Override
public void dispose() {
viewChannel = null;
}
}
26 changes: 26 additions & 0 deletions android/src/main/java/com/apxor/flutter/ApxorEmbedViewFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.apxor.flutter;

import android.content.Context;
import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import io.flutter.plugin.common.StandardMessageCodec;
import io.flutter.plugin.platform.PlatformView;
import io.flutter.plugin.platform.PlatformViewFactory;
import io.flutter.plugin.common.BinaryMessenger;
import java.util.Map;

class ApxorEmbedViewFactory extends PlatformViewFactory {
private final BinaryMessenger binaryMessenger;

public ApxorEmbedViewFactory(BinaryMessenger binaryMessenger) {
super(StandardMessageCodec.INSTANCE);
this.binaryMessenger = binaryMessenger;
}

@NonNull
@Override
public PlatformView create(@NonNull Context context, int id, @Nullable Object args) {
final Map<String, Object> creationParams = (Map<String, Object>) args;
return new ApxorEmbedView(context, id, creationParams, binaryMessenger);
}
}
40 changes: 28 additions & 12 deletions android/src/main/java/com/apxor/flutter/ApxorFlutterPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
"plugins.flutter.io/apxor_commands",
JSONMessageCodec.INSTANCE
);

registerEmbedView(flutterPluginBinding);
registerStoryView(flutterPluginBinding);
SDKController controller = SDKController.getInstance();
controller.markAsFlutter();
controller.registerToEvent(INTERNAL_EVENTS, this);
Expand Down Expand Up @@ -91,7 +92,7 @@ public void receiveAndRespond(JSONObject data, Receiver receiver) {
eName = "d";
} else if (name.equals(QYG)) {
eName = "f";
} else if (name.equals("apx_iwv")){
} else if (name.equals("apx_iwv")) {
eName = "iwv";
} else if (name.equals("apx_avf")) {
eName = "avf";
Expand Down Expand Up @@ -126,6 +127,13 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
SDKController.getInstance().setIsFlutter(false);
}

private void registerEmbedView(@NonNull FlutterPluginBinding flutterPluginBinding) {
flutterPluginBinding
.getPlatformViewRegistry()
.registerViewFactory("com.apxor.flutter/ApxorEmbedView", new ApxorEmbedViewFactory(
flutterPluginBinding.getBinaryMessenger()));
}

@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
switch (call.method) {
Expand Down Expand Up @@ -199,16 +207,16 @@ public void onEvent(BaseApxorEvent event) {
handleBB();
break;
case "d":
try{
try {
map.put("d", data.getDouble("d"));
map.put("js",data.optString("js"));
map.put("js", data.optString("js"));
map.put("root_element", data.optString("root_element"));
} catch (Exception e){
} catch (Exception e) {

}
break;
case "avf":
map.put("d",data.getDouble("d"));
map.put("d", data.getDouble("d"));
map.put("root_element", data.optString("root_element"));
break;
case "f":
Expand All @@ -222,11 +230,11 @@ public void onEvent(BaseApxorEvent event) {
map.put("msgDuration", data.getInt("msgDuration"));
map.put("uuid", data.getString("uuid"));
map.put("configName", data.getString("configName"));
map.put("js",data.getString("js"));
map.put("js", data.getString("js"));
map.put("root_element", data.optString("root_element"));
} catch (Exception e){
}
} catch (Exception e) {

}
break;
}
if (map.size() > 0) {
Expand Down Expand Up @@ -272,7 +280,7 @@ private void handleMethodCall(MethodCall call, Result result, String name) {
}
result.success(null);
} catch (Exception e) {
result.error("Apxor", "Failed to parse attributes in log" + name +"Event. " + e.getMessage(), null);
result.error("Apxor", "Failed to parse attributes in log" + name + "Event. " + e.getMessage(), null);
}
}

Expand All @@ -287,6 +295,7 @@ private void handleLogClientEvent(MethodCall call, Result result) {
private void handleLogInternalEvent(MethodCall call, Result result) {
handleMethodCall(call, result, "Internal");
}

private void handleSetUserIdentifier(MethodCall call, Result result) {
String customUserId = call.argument("userId");
ApxorSDK.setUserIdentifier(customUserId);
Expand Down Expand Up @@ -447,4 +456,11 @@ private static String h(String t) {
return new String(a);
}

private void registerStoryView(@NonNull FlutterPluginBinding flutterPluginBinding) {
flutterPluginBinding
.getPlatformViewRegistry()
.registerViewFactory("com.apxor.flutter/ApxorStoryView", new ApxorStoryViewFactory(
flutterPluginBinding.getBinaryMessenger()));
}

}
59 changes: 59 additions & 0 deletions android/src/main/java/com/apxor/flutter/ApxorStoryView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.apxor.flutter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.flutter.plugin.platform.PlatformView;
import java.util.Map;

import com.apxor.androidsdk.core.utils.Logger;
import com.apxor.androidsdk.plugins.realtimeui.stories.ApxorStoryWidget;

import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.JSONMessageCodec;
import io.flutter.plugin.common.BinaryMessenger;
import com.apxor.androidsdk.core.ce.ExecutionListener;

import org.json.JSONObject;

class ApxorStoryView implements PlatformView {
private ApxorStoryWidget apxorView;
private String tag = "";
private BasicMessageChannel<Object> viewChannel;

ApxorStoryView(@NonNull Context context, int id, @Nullable Map<String, Object> creationParams,
final BinaryMessenger binaryMessenger) {
try {
this.tag = "apx_story_" + creationParams.get("id").toString();
viewChannel = new BasicMessageChannel<>(
binaryMessenger,
"plugins.flutter.io/apxor_view_" + creationParams.get("id").toString(),
JSONMessageCodec.INSTANCE);
} catch (Exception e) {
Logger.debug("Apxor", "Flutter value key is not valid " + e.getMessage());
}
apxorView = new ApxorStoryWidget(context, tag, new ExecutionListener() {
@Override
public void onAfterExecute(Object result, boolean hasError) {
Logger.debug("Apxor", "Received dimensions from native " + result + "" + hasError);
if (result != null && viewChannel != null) {
if (result instanceof JSONObject) {
viewChannel.send(result);
}
}
}
});
}

@Override
public View getView() {
return apxorView;
}

@Override
public void dispose() {
viewChannel = null;
}
}
26 changes: 26 additions & 0 deletions android/src/main/java/com/apxor/flutter/ApxorStoryViewFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.apxor.flutter;

import android.content.Context;
import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import io.flutter.plugin.common.StandardMessageCodec;
import io.flutter.plugin.platform.PlatformView;
import io.flutter.plugin.platform.PlatformViewFactory;
import io.flutter.plugin.common.BinaryMessenger;
import java.util.Map;

class ApxorStoryViewFactory extends PlatformViewFactory {
private final BinaryMessenger binaryMessenger;

public ApxorStoryViewFactory(BinaryMessenger binaryMessenger) {
super(StandardMessageCodec.INSTANCE);
this.binaryMessenger = binaryMessenger;
}

@NonNull
@Override
public PlatformView create(@NonNull Context context, int id, @Nullable Object args) {
final Map<String, Object> creationParams = (Map<String, Object>) args;
return new ApxorStoryView(context, id, creationParams, binaryMessenger);
}
}
30 changes: 30 additions & 0 deletions ios/Classes/APXECFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// APXECFactory.h
// apxor_flutter
//
// Created by Dasari Kousik on 27/03/24.
//

#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>

NS_ASSUME_NONNULL_BEGIN

@interface APXECFactory : NSObject<FlutterPlatformViewFactory>

@property (nonatomic) NSObject<FlutterBinaryMessenger> *channelMessanger;
- (instancetype)initWithMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;
- (FlutterBasicMessageChannel*)createMessageChannel:(NSString*)channelName;

@end

@interface APXEmbeddedView : NSObject <FlutterPlatformView>
- (instancetype)initWithFrame:(CGRect)frame
viewIdentifier:(int64_t)viewId
arguments:(id _Nullable)args
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;

- (UIView*)view;
@end

NS_ASSUME_NONNULL_END
51 changes: 51 additions & 0 deletions ios/Classes/APXECFactory.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// APXECFactory.m
// apxor_flutter
//
// Created by Dasari Kousik on 27/03/24.
//

#import "APXECFactory.h"
#import "APXRTAPlugin/APXRTAPlugin.h"

@implementation APXECFactory{
NSObject<FlutterBinaryMessenger>* _messenger;
}

- (nonnull instancetype)initWithMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger {
self = [self init];
if(self){
_messenger = messenger;
}
return self;
}


- (nonnull NSObject<FlutterPlatformView> *)createWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args {
return [[APXEmbeddedView alloc] initWithFrame:frame viewIdentifier:viewId arguments:args binaryMessenger:_messenger];
}

- (NSObject<FlutterMessageCodec> *)createArgsCodec{
return FlutterStandardMessageCodec.sharedInstance;
}

@end

@implementation APXEmbeddedView{
UIView *_view;
}

- (instancetype)initWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger{
if(self = [super init]){
NSInteger tag = [[args objectForKey:@"id"] integerValue];
_view = [APXRTAPlugin initEmbedCardWithId:tag];
}
return self;
}

- (nonnull UIView *)view {
return _view;
}

@end
Loading