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

feat(OneSignal): add setOnesignalUserID method to be able to use the user-centric API integration #1202

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
String onesignalID = call.argument("onesignalID");
setOnesignalID(onesignalID, result);
break;
case "setOnesignalUserID":
String onesignalUserID = call.argument("onesignalUserID");
setOnesignalUserID(onesignalUserID, result);
break;
case "setAirshipChannelID":
String airshipChannelID = call.argument("airshipChannelID");
setAirshipChannelID(airshipChannelID, result);
Expand Down Expand Up @@ -606,6 +610,11 @@ private void setOnesignalID(String onesignalID, final Result result) {
result.success(null);
}

private void setOnesignalUserID(String onesignalUserID, final Result result) {
SubscriberAttributesKt.setOnesignalUserID(onesignalUserID);
result.success(null);
}

private void setAirshipChannelID(String airshipChannelID, final Result result) {
SubscriberAttributesKt.setAirshipChannelID(airshipChannelID);
result.success(null);
Expand Down
5 changes: 5 additions & 0 deletions api_tester/lib/api_tests/purchases_flutter_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ class _PurchasesFlutterApiTest {
Future<void> future = Purchases.setOnesignalID(id);
}

void _checkSetOnesignalUserId() {
String id = "fakeId";
Future<void> future = Purchases.setOnesignalUserID(id);
}

void _checkSetAirshipChannelId() async {
String id = "fakeId";
await Purchases.setAirshipChannelID(id);
Expand Down
8 changes: 8 additions & 0 deletions ios/Classes/PurchasesFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ - (void)handleMethodCall:(FlutterMethodCall *)call
} else if ([@"setOnesignalID" isEqualToString:call.method]) {
NSString *onesignalID = arguments[@"onesignalID"];
[self setOnesignalID:onesignalID result:result];
} else if ([@"setOnesignalUserID" isEqualToString:call.method]) {
NSString *onesignalUserID = arguments[@"onesignalUserID"];
[self setOnesignalUserID:onesignalUserID result:result];
} else if ([@"setAirshipChannelID" isEqualToString:call.method]) {
NSString *airshipChannelID = arguments[@"airshipChannelID"];
[self setAirshipChannelID:airshipChannelID result:result];
Expand Down Expand Up @@ -483,6 +486,11 @@ - (void)setOnesignalID:(nullable NSString *)onesignalID result:(FlutterResult)re
result(nil);
}

- (void)setOnesignalUserID:(nullable NSString *)onesignalUserID result:(FlutterResult)result {
[RCCommonFunctionality setOnesignalUserID:onesignalUserID];
result(nil);
}

- (void)setAirshipChannelID:(nullable NSString *)airshipChannelID result:(FlutterResult)result {
[RCCommonFunctionality setAirshipChannelID:airshipChannelID];
result(nil);
Expand Down
9 changes: 8 additions & 1 deletion lib/purchases_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -794,12 +794,19 @@ class Purchases {
);

/// Subscriber attribute associated with the OneSignal Player Id for the user
/// Required for the RevenueCat OneSignal integration
/// Required for the Device-centric RevenueCat OneSignal integration
///
/// [onesignalID] Empty String or null will delete the subscriber attribute.
static Future<void> setOnesignalID(String onesignalID) =>
_channel.invokeMethod('setOnesignalID', {'onesignalID': onesignalID});

/// Subscriber attribute associated with the OneSignal Player Id for the user
/// Required for the User-centric RevenueCat OneSignal integration
///
/// [onesignalUserID] Empty String or null will delete the subscriber attribute.
static Future<void> setOnesignalUserID(String onesignalUserID) => _channel
.invokeMethod('setOnesignalUserID', {'onesignalUserID': onesignalUserID});

/// Subscriber attribute associated with the Airship Channel Id for the user
/// Required for the RevenueCat Airship integration
///
Expand Down