Skip to content

Commit

Permalink
Merge pull request #132 from Iterable/next-version
Browse files Browse the repository at this point in the history
[MOB-2798] RN SDK release
  • Loading branch information
roninopf authored May 4, 2021
2 parents 1a45481 + 238b2c8 commit bd67f5a
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 282 deletions.
2 changes: 1 addition & 1 deletion Iterable-React-Native-SDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Pod::Spec.new do |s|

s.swift_version = '5.3'

s.dependency 'Iterable-iOS-SDK', '~> 6.2.21'
s.dependency 'Iterable-iOS-SDK', '~> 6.2.22'
s.dependency 'React-Core'
end
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def getModuleVersion() {

dependencies {
implementation 'com.facebook.react:react-native:+'
api 'com.github.Iterable.iterable-android-sdk:iterableapi:3.2.12'
api 'com.github.Iterable.iterable-android-sdk:iterableapi:3.2.13'
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ static IterableConfig.Builder getConfigFromReadableMap(ReadableMap iterableConte
configBuilder.setAutoPushRegistration(iterableContextJSON.optBoolean("autoPushRegistration"));
}

if (iterableContextJSON.has("checkForDeferredDeeplink")) {
configBuilder.setCheckForDeferredDeeplink(iterableContextJSON.optBoolean("checkForDeferredDeeplink"));
}

if (iterableContextJSON.has("inAppDisplayInterval")) {
configBuilder.setInAppDisplayInterval(iterableContextJSON.optDouble("inAppDisplayInterval"));
}
Expand Down
1 change: 0 additions & 1 deletion ios/RNIterableAPI/RNIterableAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ @interface RCT_EXTERN_REMAP_MODULE(RNIterableAPI, ReactIterableAPI, NSObject)
RCT_EXTERN_METHOD(initialize2WithApiKey: (nonnull NSString *) apiKey
config: (nonnull NSDictionary *) config
apiEndPointOverride: (nonnull NSString *) apiEndPoint
linksEndPointOverride: (nonnull NSString *) linksEndPoint
version: (nonnull NSString *) version
resolver: (RCTPromiseResolveBlock) resolve
rejecter: (RCTPromiseRejectBlock) reject)
Expand Down
8 changes: 2 additions & 6 deletions ios/RNIterableAPI/ReactIterableAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ class ReactIterableAPI: RCTEventEmitter {
rejecter: rejecter)
}

@objc(initialize2WithApiKey:config:apiEndPointOverride:linksEndPointOverride:version:resolver:rejecter:)
@objc(initialize2WithApiKey:config:apiEndPointOverride:version:resolver:rejecter:)
func initialize2(apiKey: String,
config configDict: [AnyHashable: Any],
version: String,
apiEndPointOverride: String,
linksEndPointOverride: String,
resolver: @escaping RCTPromiseResolveBlock,
rejecter: @escaping RCTPromiseRejectBlock) {
ITBInfo()
Expand All @@ -79,7 +78,6 @@ class ReactIterableAPI: RCTEventEmitter {
config: configDict,
version: version,
apiEndPointOverride: apiEndPointOverride,
linksEndPointOverride: linksEndPointOverride,
resolver: resolver,
rejecter: rejecter)
}
Expand Down Expand Up @@ -421,7 +419,6 @@ class ReactIterableAPI: RCTEventEmitter {
config configDict: [AnyHashable: Any],
version: String,
apiEndPointOverride: String? = nil,
linksEndPointOverride: String? = nil,
resolver: @escaping RCTPromiseResolveBlock,
rejecter: @escaping RCTPromiseRejectBlock) {
ITBInfo()
Expand All @@ -448,8 +445,7 @@ class ReactIterableAPI: RCTEventEmitter {
IterableAPI.initialize2(apiKey: apiKey,
launchOptions: launchOptions,
config: iterableConfig,
apiEndPointOverride: apiEndPointOverride,
linksEndPointOverride: linksEndPointOverride) { result in
apiEndPointOverride: apiEndPointOverride) { result in
resolver(result)
}
IterableAPI.setDeviceAttribute(name: "reactNativeSDKVersion", value: version)
Expand Down
5 changes: 1 addition & 4 deletions ios/RNIterableAPI/Serialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ extension IterableConfig {
config.autoPushRegistration = autoPushRegistration
}

if let checkForDeferredDeeplink = dict["checkForDeferredDeeplink"] as? Bool {
config.checkForDeferredDeeplink = checkForDeferredDeeplink
}

if let inAppDisplayInterval = dict["inAppDisplayInterval"] as? Double {
config.inAppDisplayInterval = inAppDisplayInterval
}
Expand Down Expand Up @@ -134,6 +130,7 @@ extension IterableInAppMessage {
dict["inboxMetadata"] = inboxMetadata?.toDict() ?? nil
dict["customPayload"] = customPayload
dict["read"] = read
dict["priorityLevel"] = priorityLevel
return dict
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iterable/react-native-sdk",
"version": "1.0.26",
"version": "1.0.27",
"description": "Iterable SDK for React Native.",
"main": "./js/index.js",
"types": "./js/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions ts/Iterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class IterableConfig {

/**
* When set to true, it will check for deferred deep links on first time app launch after installation from the App Store.
* This is currently deprecated and will be removed in the future.
*/
checkForDeferredDeeplink = false

Expand Down Expand Up @@ -94,7 +95,6 @@ class IterableConfig {
return {
"pushIntegrationName": this.pushIntegrationName,
"autoPushRegistration": this.autoPushRegistration,
"checkForDeferredDeeplink": this.checkForDeferredDeeplink,
"inAppDisplayInterval": this.inAppDisplayInterval,
"urlHandlerPresent": this.urlHandler != undefined,
"customActionHandlerPresent": this.customActionHandler != undefined,
Expand Down Expand Up @@ -199,13 +199,13 @@ class Iterable {
* DO NOT CALL THIS METHOD.
* This method is used internally to connect to staging environment.
*/
static initialize2(apiKey: string, config: IterableConfig = new IterableConfig(), apiEndPoint: string, linksEndPoint: string): Promise<boolean> {
static initialize2(apiKey: string, config: IterableConfig = new IterableConfig(), apiEndPoint: string): Promise<boolean> {
console.log("initialize2: " + apiKey);

this.setupEventHandlers(config)
const version = this.getVersionFromPackageJson()

return RNIterableAPI.initialize2WithApiKey(apiKey, config.toDict(), version, apiEndPoint, linksEndPoint)
return RNIterableAPI.initialize2WithApiKey(apiKey, config.toDict(), version, apiEndPoint)
}

/**
Expand Down
19 changes: 15 additions & 4 deletions ts/IterableInAppClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ class IterableInAppMessage {
* Whether this inbox message has been read
*/
readonly read: boolean
/**
* the priority value this in-app message has
*/
readonly priorityLevel: number

constructor(messageId: string,
campaignId: number,
Expand All @@ -164,7 +168,8 @@ class IterableInAppMessage {
saveToInbox: boolean,
inboxMetadata: IterableInboxMetadata | undefined,
customPayload: any | undefined,
read: boolean) {
read: boolean,
priorityLevel: number) {
this.campaignId = campaignId
this.messageId = messageId
this.trigger = trigger
Expand All @@ -174,6 +179,7 @@ class IterableInAppMessage {
this.inboxMetadata = inboxMetadata
this.customPayload = customPayload
this.read = read
this.priorityLevel = priorityLevel
}

isSilentInbox(): boolean {
Expand All @@ -186,11 +192,13 @@ class IterableInAppMessage {
const trigger = IterableInAppTrigger.fromDict(dict["trigger"])
let createdAt = dict["createdAt"]
if (createdAt) {
createdAt = new Date(createdAt as number)
var dateObject = new Date(0)
createdAt = dateObject.setUTCMilliseconds(createdAt)
}
let expiresAt = dict["expiresAt"]
if (expiresAt) {
expiresAt = new Date(expiresAt as number)
var dateObject = new Date(0)
expiresAt = dateObject.setUTCMilliseconds(expiresAt)
}
let saveToInbox = IterableUtil.readBoolean(dict, "saveToInbox")
let inboxMetadataDict = dict["inboxMetadata"]
Expand All @@ -203,6 +211,8 @@ class IterableInAppMessage {
let customPayload = dict["customPayload"]
let read = IterableUtil.readBoolean(dict, "read")

let priorityLevel = dict["priorityLevel"] as number

return new IterableInAppMessage(
messageId,
campaignId,
Expand All @@ -212,7 +222,8 @@ class IterableInAppMessage {
saveToInbox,
inboxMetadata,
customPayload,
read
read,
priorityLevel
)
}

Expand Down
2 changes: 0 additions & 2 deletions ts/__tests__/Iterable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ test("default config values", () => {

expect(config.pushIntegrationName).toBe(undefined)
expect(config.autoPushRegistration).toBe(true)
expect(config.checkForDeferredDeeplink).toBe(false)
expect(config.inAppDisplayInterval).toBe(30.0)
expect(config.urlHandler).toBe(undefined)
expect(config.customActionHandler).toBe(undefined)
Expand All @@ -130,7 +129,6 @@ test("default config dictionary values", () => {

expect(configDict["pushIntegrationName"]).toBe(undefined)
expect(configDict["autoPushRegistration"]).toBe(true)
expect(configDict["checkForDeferredDeeplink"]).toBe(false)
expect(configDict["inAppDisplayInterval"]).toBe(30.0)
expect(configDict["urlHandlerPresent"]).toBe(false)
expect(configDict["customActionHandlerPresent"]).toBe(false)
Expand Down
11 changes: 6 additions & 5 deletions ts/__tests__/IterableInApp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ beforeEach(() => {
})

test("trackInAppOpen", () => {
let msg: IterableInAppMessage = new IterableInAppMessage("someMessageId", 123, new IterableInAppTrigger(IterableInAppTriggerType.event), new Date(1234), new Date(123123), true, new IterableInboxMetadata("title", "subtitle", "iconURL"), { "CustomPayloadKey": "CustomPayloadValue" }, false);
let msg: IterableInAppMessage = new IterableInAppMessage("someMessageId", 123, new IterableInAppTrigger(IterableInAppTriggerType.event), new Date(1234), new Date(123123), true, new IterableInboxMetadata("title", "subtitle", "iconURL"), { "CustomPayloadKey": "CustomPayloadValue" }, false, 300.5);
Iterable.trackInAppOpen(
msg,
IterableInAppLocation.inApp
Expand All @@ -38,7 +38,7 @@ test("trackInAppOpen", () => {
})

test("trackInAppClick", () => {
let msg: IterableInAppMessage = new IterableInAppMessage("someMessageId", 123, new IterableInAppTrigger(IterableInAppTriggerType.event), new Date(1234), new Date(123123), true, new IterableInboxMetadata("title", "subtitle", "iconURL"), { "CustomPayloadKey": "CustomPayloadValue" }, false);
let msg: IterableInAppMessage = new IterableInAppMessage("someMessageId", 123, new IterableInAppTrigger(IterableInAppTriggerType.event), new Date(1234), new Date(123123), true, new IterableInboxMetadata("title", "subtitle", "iconURL"), { "CustomPayloadKey": "CustomPayloadValue" }, false, 300.5);
Iterable.trackInAppClick(
msg,
IterableInAppLocation.inApp,
Expand All @@ -53,7 +53,7 @@ test("trackInAppClick", () => {
})

test("trackInAppClose", () => {
let msg: IterableInAppMessage = new IterableInAppMessage("someMessageId", 123, new IterableInAppTrigger(IterableInAppTriggerType.event), new Date(1234), new Date(123123), true, new IterableInboxMetadata("title", "subtitle", "iconURL"), { "CustomPayloadKey": "CustomPayloadValue" }, false);
let msg: IterableInAppMessage = new IterableInAppMessage("someMessageId", 123, new IterableInAppTrigger(IterableInAppTriggerType.event), new Date(1234), new Date(123123), true, new IterableInboxMetadata("title", "subtitle", "iconURL"), { "CustomPayloadKey": "CustomPayloadValue" }, false, 300.5);
Iterable.trackInAppClose(
msg,
IterableInAppLocation.inbox,
Expand All @@ -70,7 +70,7 @@ test("trackInAppClose", () => {
})

test("in-app consume", () => {
let message = new IterableInAppMessage("asdf", 1234, new IterableInAppTrigger(IterableInAppTriggerType.never), undefined, undefined, false, undefined, undefined, false)
let message = new IterableInAppMessage("asdf", 1234, new IterableInAppTrigger(IterableInAppTriggerType.never), undefined, undefined, false, undefined, undefined, false, 300.5)

Iterable.inAppConsume(message, IterableInAppLocation.inApp, IterableInAppDeleteSource.unknown)

Expand All @@ -94,12 +94,13 @@ test("in-app handler is called", () => {
"messageId": "message1",
"campaignId": 1234,
"trigger": { "type": IterableInAppTriggerType.immediate },
"priorityLevel": 300.5
}
nativeEmitter.emit(EventName.handleInAppCalled, messageDict);

return TestHelper.delayed(0, () => {
expect(config.inAppHandler)
const expectedMessage = new IterableInAppMessage("message1", 1234, new IterableInAppTrigger(IterableInAppTriggerType.immediate), undefined, undefined, false, undefined, undefined, false)
const expectedMessage = new IterableInAppMessage("message1", 1234, new IterableInAppTrigger(IterableInAppTriggerType.immediate), undefined, undefined, false, undefined, undefined, false, 300.5)
expect(config.inAppHandler).toBeCalledWith(expectedMessage)
expect(MockRNIterableAPI.setInAppShowResponse).toBeCalledWith(IterableInAppShowResponse.show)
})
Expand Down
Loading

0 comments on commit bd67f5a

Please sign in to comment.