Skip to content

Commit b259cba

Browse files
chore: Add deleteDeviceToken API (#257)
1 parent 87abf93 commit b259cba

File tree

8 files changed

+32
-1
lines changed

8 files changed

+32
-1
lines changed

android/src/main/kotlin/io/customer/customer_io/CustomerIOPlugin.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class CustomerIOPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
6464
override fun onMethodCall(call: MethodCall, result: Result) {
6565
when (call.method) {
6666
"clearIdentify" -> call.nativeNoArgs(result, ::clearIdentify)
67+
"deleteDeviceToken" -> call.nativeNoArgs(result, ::deleteDeviceToken)
6768
"identify" -> call.nativeMapArgs(result, ::identify)
6869
"initialize" -> call.nativeMapArgs(result, ::initialize)
6970
"registerDeviceToken" -> call.nativeMapArgs(result, ::registerDeviceToken)
@@ -118,6 +119,10 @@ class CustomerIOPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
118119
CustomerIO.instance().registerDeviceToken(token)
119120
}
120121

122+
private fun deleteDeviceToken() {
123+
CustomerIO.instance().deleteDeviceToken()
124+
}
125+
121126
private fun trackMetric(params: Map<String, Any>) {
122127
val deliveryId = params.getAs<String>(Args.DELIVERY_ID)
123128
val deliveryToken = params.getAs<String>(Args.DELIVERY_TOKEN)

apps/amiapp_flutter/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ packages:
103103
path: "../.."
104104
relative: true
105105
source: path
106-
version: "2.4.1"
106+
version: "2.4.2"
107107
dbus:
108108
dependency: transitive
109109
description:

customerio-flutter.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public final class CustomerIO {
1313
CustomerIOMessagingPushPlatform? pushMessaging,
1414
CustomerIOMessagingInAppPlatform? inAppMessaging
1515
): CustomerIO;
16+
public fun deleteDeviceToken();
1617
public fun identify(
1718
required String userId,
1819
Map<String, dynamic> traits
@@ -95,6 +96,7 @@ public final class CustomerIOMessagingPushPlatform {
9596
public final class CustomerIOPlatform {
9697
public fun new(): CustomerIOPlatform;
9798
public fun clearIdentify();
99+
public fun deleteDeviceToken();
98100
public fun identify(
99101
required String userId,
100102
Map<String, dynamic> traits

ios/Classes/SwiftCustomerIOPlugin.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public class SwiftCustomerIOPlugin: NSObject, FlutterPlugin {
3030
case "clearIdentify":
3131
call.nativeNoArgs(result: result, handler: clearIdentify)
3232

33+
case "deleteDeviceToken":
34+
call.nativeNoArgs(result: result, handler: deleteDeviceToken)
35+
3336
case "identify":
3437
call.nativeMapArgs(result: result, handler: identify)
3538

@@ -131,6 +134,10 @@ public class SwiftCustomerIOPlugin: NSObject, FlutterPlugin {
131134
CustomerIO.shared.registerDeviceToken(token)
132135
}
133136

137+
private func deleteDeviceToken() {
138+
CustomerIO.shared.deleteDeviceToken()
139+
}
140+
134141
private func trackMetric(params: [String: AnyHashable]) {
135142
guard let deliveryId: String = params.require(Args.deliveryId),
136143
let deviceToken: String = params.require(Args.deliveryToken),

lib/customer_io.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ class CustomerIO {
133133
return _platform.registerDeviceToken(deviceToken: deviceToken);
134134
}
135135

136+
/// Delete a device token that was previously registered with Customer.io
137+
void deleteDeviceToken() {
138+
return _platform.deleteDeviceToken();
139+
}
140+
136141
/// Track screen events to record the screens a user visits
137142
///
138143
/// @param name name of the screen user visited

lib/data_pipelines/_native_constants.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class NativeMethods {
77
static const String setDeviceAttributes = "setDeviceAttributes";
88
static const String setProfileAttributes = "setProfileAttributes";
99
static const String registerDeviceToken = "registerDeviceToken";
10+
static const String deleteDeviceToken = "deleteDeviceToken";
1011
static const String track = "track";
1112
static const String trackMetric = "trackMetric";
1213
}

lib/data_pipelines/customer_io_method_channel.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ class CustomerIOMethodChannel extends CustomerIOPlatform {
7979
});
8080
}
8181

82+
/// Delete a device token that was previously registered with Customer.io
83+
@override
84+
void deleteDeviceToken() {
85+
return methodChannel
86+
.invokeNativeMethodVoid(NativeMethods.deleteDeviceToken);
87+
}
88+
8289
/// Call this function to stop identifying a person.
8390
@override
8491
void clearIdentify() {

lib/data_pipelines/customer_io_platform_interface.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ abstract class CustomerIOPlatform extends PlatformInterface {
5858
throw UnimplementedError('registerDeviceToken() has not been implemented.');
5959
}
6060

61+
void deleteDeviceToken() {
62+
throw UnimplementedError('deleteDeviceToken() has not been implemented.');
63+
}
64+
6165
void screen(
6266
{required String title, Map<String, dynamic> properties = const {}}) {
6367
throw UnimplementedError('screen() has not been implemented.');

0 commit comments

Comments
 (0)