Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
example/ios/Podfile.lock
example/pubspec.lock
example/pubspec.lock
.dart_tool/
build/
pubspec.lock
5 changes: 4 additions & 1 deletion android/build.gradle

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PRs should be scoped specifically to what they're trying to do - support JWT in this case. Is is necessary to change this in order to do that? Maybe consider creating another PR for whatever you need these changes for.

Imagine if something in these new versions broke and needed to revert this PR - now we lose JWTs! Or have to spend extra time cherrypicking exactly what we need to revert.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'com.iterable:iterableapi:3.4.9'
implementation 'com.iterable:iterableapi:3.4.15'
implementation 'com.iterable:iterableapi-ui:3.4.0'
// Version 17.4.0+ is required for push notifications and in-app message features:
implementation 'com.google.firebase:firebase-messaging:17.4.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20210307'
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class IterableFlutterPlugin : FlutterPlugin, MethodCallHandler {
result.success(null)
}
"setEmail" -> {
val userEmail = call.arguments as String
IterableApi.getInstance().setEmail(userEmail)
IterableApi.getInstance().registerForPush()
val email = call.argument<String>("email") ?: ""
val jwt = call.argument<String>("jwt") ?: ""
IterableApi.getInstance().setEmail(email, jwt)
result.success(null)
}
"setUserId" -> {
Expand Down Expand Up @@ -107,11 +107,10 @@ class IterableFlutterPlugin : FlutterPlugin, MethodCallHandler {
notifyPushNotificationOpened()
false
}

if (activeLogDebug) {
configBuilder.setLogLevel(Log.DEBUG)
configBuilder.setLogLevel(Log.VERBOSE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not necessary to include in the PR and probably makes sense to change locally when you need to check logs for something.

}

IterableApi.initialize(context, apiKey, configBuilder.build())
}

Expand Down
6 changes: 4 additions & 2 deletions ios/Classes/SwiftIterableFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public class SwiftIterableFlutterPlugin: NSObject, FlutterPlugin, UNUserNotifica

result(nil)
case "setEmail":
let email = call.arguments as! String
IterableAPI.email = email
let args = getPropertiesFromArguments(call.arguments)
let email = args["email"] as! String
let jwt = args["jwt"] as! String
IterableAPI.setEmail(email, jwt)

result(nil)
case "setUserId":
Expand Down
10 changes: 8 additions & 2 deletions lib/iterable_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ class IterableFlutter {
_channel.setMethodCallHandler(nativeMethodCallHandler);
}

static Future<void> setEmail(String email) async {
await _channel.invokeMethod('setEmail', email);
static Future<void> setEmail(String email, String jwt) async {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make jwt nullable in order to communicate that it isn't strictly required. Some implementations either don't care about having a JWT, or just want to get something quick put together to ensure the package works.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No support for setUserId? Seems easy enough to add.

await _channel.invokeMethod(
'setEmail',
{
'email': email,
'jwt': jwt,
},
);
}

static Future<void> setUserId(String userId) async {
Expand Down
8 changes: 6 additions & 2 deletions test/iterable_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void main() {
const String activeLogDebug = 'activeLogDebug';
const String email = 'my@email.com';
const String userId = '11111';
const String jwt = '';
const String event = 'my_event';
const Map<String, dynamic> dataFields = {'data': 'field'};

Expand Down Expand Up @@ -71,9 +72,12 @@ void main() {
});

test('setEmail', () async {
await IterableFlutter.setEmail(email);
await IterableFlutter.setEmail(email, jwt);
expect(calledMethod, <Matcher>[
isMethodCall('setEmail', arguments: email),
isMethodCall('setEmail', arguments: {
"email": email,
"jwt": jwt
}),
]);
});

Expand Down