Skip to content
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Unreleased

### Updates

- Added `Iterable.disableDeviceForAllUsers()` to unregister this device's push token from every user associated with the device (SDK-550).
- iOS: forwards to native `IterableAPI.disableDeviceForAllUsers()`.
- Android: graceful no-op that logs a warning; use `disableDeviceForCurrentUser()` to disable push for the current user. There is no public native "all users" equivalent.

## 3.1.0

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ public void disableDeviceForCurrentUser() {
IterableApi.getInstance().disablePush();
}

public void disableDeviceForAllUsers() {
IterableLogger.w(TAG, "disableDeviceForAllUsers is not supported on Android; use disableDeviceForCurrentUser. There is no public native equivalent.");
}

public void registerDeviceToken(String token) {
IterableLogger.v(TAG, "registerDeviceToken");
IterableApi.getInstance().registerDeviceToken(token);
Expand Down
5 changes: 5 additions & 0 deletions android/src/newarch/java/com/RNIterableAPIModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public void disableDeviceForCurrentUser() {
moduleImpl.disableDeviceForCurrentUser();
}

@Override
public void disableDeviceForAllUsers() {
moduleImpl.disableDeviceForAllUsers();
}

@Override
public void registerDeviceToken(String token) {
moduleImpl.registerDeviceToken(token);
Expand Down
5 changes: 5 additions & 0 deletions android/src/oldarch/java/com/RNIterableAPIModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public void disableDeviceForCurrentUser() {
moduleImpl.disableDeviceForCurrentUser();
}

@ReactMethod
public void disableDeviceForAllUsers() {
moduleImpl.disableDeviceForAllUsers();
}

@ReactMethod
public void registerDeviceToken(String token) {
moduleImpl.registerDeviceToken(token);
Expand Down
8 changes: 8 additions & 0 deletions ios/RNIterableAPI/RNIterableAPI.mm
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ - (void)disableDeviceForCurrentUser {
[_swiftAPI disableDeviceForCurrentUser];
}

- (void)disableDeviceForAllUsers {
[_swiftAPI disableDeviceForAllUsers];
}

- (void)registerDeviceToken:(NSString *)token {
[_swiftAPI registerDeviceToken:token];
}
Expand Down Expand Up @@ -516,6 +520,10 @@ - (void)wakeApp {
[_swiftAPI disableDeviceForCurrentUser];
}

RCT_EXPORT_METHOD(disableDeviceForAllUsers) {
[_swiftAPI disableDeviceForAllUsers];
}

RCT_EXPORT_METHOD(registerDeviceToken : (NSString *)token) {
[_swiftAPI registerDeviceToken:token];
}
Expand Down
6 changes: 6 additions & 0 deletions ios/RNIterableAPI/ReactIterableAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ import React
IterableAPI.disableDeviceForCurrentUser()
}

@objc(disableDeviceForAllUsers)
public func disableDeviceForAllUsers() {
ITBInfo()
IterableAPI.disableDeviceForAllUsers()
}

@objc(registerDeviceToken:)
public func registerDeviceToken(token: String) {
ITBInfo()
Expand Down
2 changes: 2 additions & 0 deletions src/__mocks__/MockRNIterableAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export class MockRNIterableAPI {

static disableDeviceForCurrentUser = jest.fn();

static disableDeviceForAllUsers = jest.fn();

static registerDeviceToken = jest.fn((token: string): void => {
MockRNIterableAPI.token = token;
});
Expand Down
1 change: 1 addition & 0 deletions src/api/NativeRNIterableAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface Spec extends TurboModule {

// Device management
disableDeviceForCurrentUser(): void;
disableDeviceForAllUsers(): void;
registerDeviceToken(token: string): void;
getLastPushPayload(): Promise<{
[key: string]: string | number | boolean;
Expand Down
10 changes: 10 additions & 0 deletions src/core/classes/Iterable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ describe('Iterable', () => {
});
});

describe('disableDeviceForAllUsers', () => {
it('should disable the device for all users', () => {
// GIVEN no parameters
// WHEN Iterable.disableDeviceForAllUsers is called
Iterable.disableDeviceForAllUsers();
// THEN corresponding method is called on RNIterableAPI
expect(MockRNIterableAPI.disableDeviceForAllUsers).toBeCalled();
});
});

describe('registerDeviceToken', () => {
it('should register the device token for the current user', () => {
// GIVEN a device token
Expand Down
20 changes: 20 additions & 0 deletions src/core/classes/Iterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,26 @@ export class Iterable {
IterableApi.disableDeviceForCurrentUser();
}

/**
* Disable this device's push token for every user associated with the device,
* not only the currently signed-in user.
*
* On iOS this forwards to native `IterableAPI.disableDeviceForAllUsers()`.
* On Android this is a no-op that logs a warning: the native Android SDK has
* no public "all users" equivalent. Use {@link disableDeviceForCurrentUser} to
* disable push for the current user on both platforms.
*
* Fire-and-forget: native success or failure is not surfaced to JS.
*
* @example
* ```typescript
* Iterable.disableDeviceForAllUsers();
* ```
*/
static disableDeviceForAllUsers() {
IterableApi.disableDeviceForAllUsers();
}

/**
* Register the device's token for the current user, re-enabling push notifications.
*
Expand Down
11 changes: 11 additions & 0 deletions src/core/classes/IterableApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ describe('IterableApi', () => {
});
});

describe('disableDeviceForAllUsers', () => {
it('should call RNIterableAPI.disableDeviceForAllUsers', () => {
// GIVEN no parameters
// WHEN disableDeviceForAllUsers is called
IterableApi.disableDeviceForAllUsers();

// THEN RNIterableAPI.disableDeviceForAllUsers is called
expect(MockRNIterableAPI.disableDeviceForAllUsers).toBeCalled();
});
});

describe('registerDeviceToken', () => {
it('should call RNIterableAPI.registerDeviceToken with the token', () => {
// GIVEN a device token
Expand Down
11 changes: 11 additions & 0 deletions src/core/classes/IterableApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ export class IterableApi {
return RNIterableAPI.disableDeviceForCurrentUser();
}

/**
* Disable this device's push token for every user associated with the device.
*
* iOS: forwards to native `IterableAPI.disableDeviceForAllUsers()`.
* Android: logged no-op β€” there is no public native "all users" equivalent.
*/
static disableDeviceForAllUsers() {
IterableLogger.log('disableDeviceForAllUsers');
return RNIterableAPI.disableDeviceForAllUsers();
}

/**
* Register the device token for the current user, re-enabling push notifications.
*
Expand Down
Loading