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
@Override | |
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { | |
if (call.method.equals("getBatteryLevel")) { | |
result.success(99); | |
} else { | |
result.notImplemented(); | |
} | |
} |
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
@Override | |
public void onAttachedToEngine( | |
@NonNull FlutterPluginBinding flutterPluginBinding | |
) { | |
channel = | |
new MethodChannel( | |
flutterPluginBinding.getBinaryMessenger(), | |
"org.rudderstack.dev/battery" | |
); | |
channel.setMethodCallHandler(this); |
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
// Get battery level. | |
static Future<String> getBatteryLevel() async { | |
String batteryLevel; | |
try { | |
final int result = await _channel.invokeMethod('getBatteryLevel'); | |
batteryLevel = 'Battery level: $result%.'; | |
} on PlatformException { | |
batteryLevel = 'Failed to get battery level.'; | |
} | |
return batteryLevel; |
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
import 'dart:async'; | |
import 'package:flutter/services.dart'; | |
class BatteryLevel { | |
static const MethodChannel _channel = | |
MethodChannel('org.rudderstack.dev/battery'); | |
// Get battery level. | |
} |
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
flutter create --org com.rudderstack --template=plugin --platforms=android,ios -a java -i objc batteryLevel |
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
rudderanalytics.identify('a1b2c3d4e5f6g7h8i9', | |
traits: { | |
email: ‘eric@rudderstack.com’, | |
recent_five_purchases: { | |
purchase_1: ‘1578973’, |
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
recent_five_purchases: { | |
purchase_1: ‘1578973’, | |
purchase_2: ‘265098, | |
purchase_3: 998145, | |
purchase_4: null, |
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
// pseudo-code to retrieve user and recent purchases | |
redis.call(“hget”, “user:”+userId+”:session:”_sessionId, “membership_status”, “income_bracket”, “recent_five_purchases”); | |
// pseudo-code to determine recommendations based on user and recent purchases | |
recommendations = getProductRecommendations(userId, recent_five_purchases) |
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
[ | |
"properties.sale_item" | |
] | |