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
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ public void disableDeviceForCurrentUser() {
IterableApi.getInstance().disablePush();
}

@ReactMethod
public void registerDeviceToken(String deviceToken) {
IterableLogger.v(TAG, "registerDeviceToken");
IterableApi.getInstance().registerDeviceToken(deviceToken);
}

@ReactMethod
public void handleAppLink(String uri, Promise promise) {
IterableLogger.printInfo();
Expand Down
2 changes: 2 additions & 0 deletions ios/RNIterableAPI/RNIterableAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ @interface RCT_EXTERN_REMAP_MODULE(RNIterableAPI, ReactIterableAPI, NSObject)

RCT_EXTERN_METHOD(disableDeviceForCurrentUser)

RCT_EXTERN_METHOD(registerDeviceToken: (nonnull NSString *) token)

RCT_EXTERN_METHOD(setInAppShowResponse: (nonnull NSNumber *) inAppShowResponse)

RCT_EXTERN_METHOD(getLastPushPayload: (RCTPromiseResolveBlock) resolve
Expand Down
11 changes: 11 additions & 0 deletions ios/RNIterableAPI/ReactIterableAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ class ReactIterableAPI: RCTEventEmitter {
inAppHandlerSemaphore.signal()
}

@objc(registerDeviceToken:)
func registerDeviceToken(token: String) {
ITBInfo()

if let deviceTokenData = token.data(using: .utf8) {
IterableAPI.register(token: deviceTokenData)
} else {
ITBInfo("Failed to convert device token string to data")
}
}

@objc(disableDeviceForCurrentUser)
func disableDeviceForCurrentUser() {
ITBInfo()
Expand Down
12 changes: 12 additions & 0 deletions ts/Iterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,18 @@ class Iterable {
RNIterableAPI.disableDeviceForCurrentUser()
}

/**
* Registers a device token with Iterable.
* Make sure IterableConfig.pushIntegrationName is set before calling this.
* @param {string} deviceToken Push token obtained from GCM or FCM.
*/

static registerDeviceToken(deviceToken: string) {
Iterable.logger.log("registerDeviceToken")

RNIterableAPI.registerDeviceToken(deviceToken)
}

/**
* This static method returns the payload of the last push notification with which the user
* opened the application (by clicking an action button, etc.).
Expand Down