Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to unification of the two platforms  iOS and Android API #6

Closed
lessthanno opened this issue Nov 4, 2019 · 6 comments
Closed

Comments

@lessthanno
Copy link

I don't know.
how to pass the value is correct.

Eg. iOS FB API.

func logAddToWishlistEvent(contentData : String, contentId : String, contentType : String, currency : String, price : Double) {
let params : AppEvent.ParametersDictionary = [
.content : contentData,
.contentId : contentId,
.contentType : contentType,
.currency : currency
]
let event = AppEvent(name: .addedToWishlist, parameters: params, valueToSum: price)
AppEventsLogger.log(event)
}

Eg. Android
/**

This function assumes logger is an instance of AppEventsLogger and has been
created using AppEventsLogger.newLogger() call.
*/
public void logAddToWishlistEvent (String contentData, String contentId, String contentType, String currency, double price) {
Bundle params = new Bundle();
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT, contentData);
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, contentId);
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, contentType);
params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency);
logger.logEvent(AppEventsConstants.EVENT_NAME_ADDED_TO_WISHLIST, price, params);
}
The FB API names of the two platforms are different.

Q. Then how should I pass in flutter_app_event?

@DennisAlund
Copy link
Member

The predefined app event constants has not yet been implemented. It's a good idea for a pull request though.... or hang tight and I'll find a bit of time in near future to implement it.

@lessthanno
Copy link
Author

I compare the APIs of FB's two platforms(iOS / android).

eg. EVENT_NAME_ACTIVATED_APP

// android event name :
public static final String EVENT_NAME_ACTIVATED_APP = "fb_mobile_activate_app";

// ios event name :
static NSString *const FBSDKAppEventNameActivatedApp = @"fb_mobile_activate_app";

I need to rewrite each of the required names by flutter instead of calling the original api

@lessthanno
Copy link
Author

The predefined app event constants has not yet been implemented. It's a good idea for a pull request though.... or hang tight and I'll find a bit of time in near future to implement it.

I extracted every api I needed and temporarily implemented it.

eg facebookAppEvents.logEvent(name:‘ fb_mobile_activate_app’)

@DennisAlund
Copy link
Member

Ya, that's the way to do it. The only difference after adding to the plugin is that you get a corresponding constant to refer to: FacebookAppEvents.EVENT_NAME_ACTIVATED_APP

The way that FirebaseAnalytics for Flutter has solved it is that they're implementing a method for each named event. That might also be a way to go about it.

https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_analytics/lib/firebase_analytics.dart#L235-L237

@DennisAlund
Copy link
Member

I've implemented a sample of "activate app" as mentioned in your issue (see commit: efd52f6)

I'll implement further support for more events later... or feel free to follow the example by adding more methods and declarations in the same pattern and make a pull request.

@DennisAlund
Copy link
Member

I'll close this issue as the current answer is to just use the generic logEvent method and look up the event constant name in the source code of the Facebook SDK here: https://github.com/facebook/facebook-android-sdk/blob/master/facebook-core/src/main/java/com/facebook/appevents/AppEventsConstants.java

Thank you for the input and I will start implementing support for the other event codes and accept good pull requests to help completing the list of support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants