Skip to content

Commit

Permalink
Updates to iOS 1.7.1 and Android 1.6.0 [sc-131553] (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
chayelheinsen authored Nov 22, 2024
1 parent ab8a484 commit ff1d9c0
Show file tree
Hide file tree
Showing 16 changed files with 1,047 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ android/keystores/debug.keystore
# generated by bob
lib/
.yarn/install-state.gz
example/.yarn/install-state.gz
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.0
20.18.0
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 18.16.0
nodejs 20.18.0
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.movableink.sdk:inked:1.5.4"
implementation "com.movableink.sdk:inked:1.6.0"
}

if (isNewArchitectureEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RNMovableInkModule(reactContext: ReactApplicationContext) :

@ReactMethod
fun identifyUser() {
MIClient.identifyUser()

}

@ReactMethod
Expand Down
Binary file removed example/.yarn/install-state.gz
Binary file not shown.
934 changes: 934 additions & 0 deletions example/.yarn/releases/yarn-4.5.1.cjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions example/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarnPath: .yarn/releases/yarn-4.5.1.cjs
2 changes: 1 addition & 1 deletion example/ios/.xcode.env.local
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export NODE_BINARY=/Users/cheinsen/.nvm/versions/node/v18.16.1/bin/node
export NODE_BINARY=~/.asdf/shims/node

12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ PODS:
- hermes-engine/Pre-built (= 0.73.5)
- hermes-engine/Pre-built (0.73.5)
- libevent (2.1.12)
- MovableInk (1.6.5)
- MovableInk (1.7.1)
- OpenSSL-Universal (1.1.1100)
- RCT-Folly (2022.05.16.00):
- boost
Expand Down Expand Up @@ -945,8 +945,8 @@ PODS:
- React-Mapbuffer (0.73.5):
- glog
- React-debug
- react-native-movable-ink (1.5.8):
- MovableInk (= 1.6.5)
- react-native-movable-ink (1.6.0):
- MovableInk (= 1.7.1)
- React-Core
- React-nativeconfig (0.73.5)
- React-NativeModulesApple (0.73.5):
Expand Down Expand Up @@ -1336,7 +1336,7 @@ SPEC CHECKSUMS:
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 1d1835b2cc54c381909d94d1b3c8e0a2f1a94a0e
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
MovableInk: 60c93c909eca678a5c91755e966cb0a4bba37817
MovableInk: fbc06caa29a94071c91df984d38fbc9bfa52f7c8
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
RCTRequired: 2544c0f1081a5fa12e108bb8cb40e5f4581ccd87
Expand All @@ -1359,7 +1359,7 @@ SPEC CHECKSUMS:
React-jsinspector: 32db5e364bcae8fca8cdf8891830636275add0c5
React-logger: 0331362115f0f5b392bd7ed14636d1a3ea612479
React-Mapbuffer: 7c35cd53a22d0be04d3f26f7881c7fb7dd230216
react-native-movable-ink: ec23a7fa908174dcc9584cf3519dabd906acf93a
react-native-movable-ink: c3fd652de2dce34f893c55d5acb4b64bbb378ec2
React-nativeconfig: 1166714a4f7ea57a0df5c2cb44fbc70f98d580f9
React-NativeModulesApple: 726664e9829eb5eed8170241000e46ead269a05f
React-perflogger: 0dd9f1725d55f8264b81efadd373fe1d9cca7dc2
Expand All @@ -1386,4 +1386,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: d92c2cd8a63b55c2d5826992fcf5678d25e7d24e

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
},
"engines": {
"node": ">=18"
}
},
"packageManager": "[email protected]"
}
16 changes: 16 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ export default function App() {
}}
/>

<Button
title="Test Product Added"
onPress={(_event) => {
RNMovableInk.productAdded({
id: '123',
title: 'Test Product',
price: '$10.00',
meta: {
test_key: 'test_value',
test_key_two: true,
test_key_three: 12345,
},
});
}}
/>

<Button
title="Test Custom Event"
onPress={(_event) => {
Expand Down
124 changes: 79 additions & 45 deletions ios/RNMovableInk.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import MovableInk

@objc(RNMovableInk)
public class RNMovableInk: NSObject {
public class RNMovableInk: NSObject {
@objc(start)
public func start() {
MIClient.start { _ in }
Task { @MainActor in
MIClient.start { _ in }
}
}

@objc(setMIU:)
public func setMIU(value: String) {
MIClient.setMIU(value)
Task { @MainActor in
MIClient.setMIU(value)
}
}

@objc(setAppInstallEventEnabled:)
public func setAppInstallEventEnabled(enabled: Bool) {
MIClient.appInstallEventEnabled = enabled
Task { @MainActor in
MIClient.appInstallEventEnabled = enabled
}
}

@objc(resolveURL:withResolver:withRejecter:)
Expand All @@ -23,100 +29,128 @@ public class RNMovableInk: NSObject {
resolve: @escaping RCTPromiseResolveBlock,
reject: @escaping RCTPromiseRejectBlock
) {
guard let url = URL(string: link) else {
reject(
"-1",
"link could not be coerced to URL",
NSError(domain: "com.movableink.sdk", code: -1)
)

return
}

if !MIClient.canHandleURL(url) {
resolve(nil)
return
}

MIClient.resolve(url: url) { result in
switch result {
case let .success(clickthrough):
resolve(clickthrough.absoluteString)

case let .failure(.failure(failedURL, message)):
Task { @MainActor in
guard let url = URL(string: link) else {
reject(
"-1",
"\(failedURL) - \(message)",
"link could not be coerced to URL",
NSError(domain: "com.movableink.sdk", code: -1)
)

default:
reject(
"-1",
"failed to resolve link",
NSError(domain: "com.movableink.sdk", code: -1)
)
return
}

if !MIClient.canHandleURL(url) {
resolve(nil)
return
}

MIClient.resolve(url: url) { result in
switch result {
case let .success(clickthrough):
resolve(clickthrough.absoluteString)

case let .failure(.failure(failedURL, message)):
reject(
"-1",
"\(failedURL) - \(message)",
NSError(domain: "com.movableink.sdk", code: -1)
)

default:
reject(
"-1",
"failed to resolve link",
NSError(domain: "com.movableink.sdk", code: -1)
)
}
}
}
}

@objc(checkPasteboardOnInstall:withRejecter:)
public func checkPasteboardOnInstall(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
Task {
Task { @MainActor in
let value = await MIClient.checkPasteboardOnInstall()
resolve(value?.absoluteString)
}
}

@objc(showInAppMessage:withCallback:)
public func showInAppMessage(link: String, callback: @escaping RCTResponseSenderBlock) {
MIClient.showInAppMessage(with: link) { buttonID in
callback([buttonID])
Task { @MainActor in
MIClient.showInAppMessage(with: link) { buttonID in
callback([buttonID])
}
}
}
}

@objc(productSearched:)
public func productSearched(properties: [String: Any]) {
MIClient.productSearched(properties)
Task { @MainActor in
guard let properties = properties as? [String: Sendable] else { return }
MIClient.productSearched(properties)
}
}

@objc(productViewed:)
public func productViewed(properties: [String: Any]) {
MIClient.productViewed(properties)
Task { @MainActor in
guard let properties = properties as? [String: Sendable] else { return }
MIClient.productViewed(properties)
}
}

@objc(productAdded:)
public func productAdded(properties: [String: Any]) {
MIClient.productAdded(properties)
Task { @MainActor in
guard let properties = properties as? [String: Sendable] else { return }
MIClient.productAdded(properties)
}
}

@objc(productRemoved:)
public func productRemoved(properties: [String: Any]) {
MIClient.productRemoved(properties)
Task { @MainActor in
guard let properties = properties as? [String: Sendable] else { return }
MIClient.productRemoved(properties)
}
}

@objc(orderCompleted:)
public func orderCompleted(properties: [String: Any]) {
MIClient.orderCompleted(properties)
Task { @MainActor in
guard let properties = properties as? [String: Sendable] else { return }
MIClient.orderCompleted(properties)
}
}

@objc(categoryViewed:)
public func categoryViewed(properties: [String: Any]) {
MIClient.categoryViewed(properties)
Task { @MainActor in
guard let properties = properties as? [String: Sendable] else { return }
MIClient.categoryViewed(properties)
}
}

@objc(logEvent:withProperties:)
public func logEvent(name: String, properties: [String: Any]) {
MIClient.logEvent(name: name, properties: properties)
Task { @MainActor in
guard let properties = properties as? [String: Sendable] else { return }
MIClient.logEvent(name: name, properties: properties)
}
}

@objc(identifyUser)
public func identifyUser() {
MIClient.identifyUser()
// identifyUser is deprecated.
// But we'll keep this for now to not break existing implementations.
}

@objc(setValidPasteboardValues:)
public func setValidPasteboardValues(values: [String]) {
MIClient.validPasteboardValues = values
Task { @MainActor in
MIClient.validPasteboardValues = values
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@movable/react-native-sdk",
"version": "1.5.9",
"version": "1.6.0",
"description": "MovableInk React Native SDK",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
2 changes: 1 addition & 1 deletion react-native-movable-ink.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|

s.source_files = "ios/**/*.{h,m,mm,swift}"

s.dependency "MovableInk", "1.6.5"
s.dependency "MovableInk", "1.7.1"
s.dependency "React-Core"

# Don't install the dependencies when we run `pod install` in the old architecture.
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ProductProperties {
price?: string;
url?: string;
categories?: Array<ProductCategory>;
meta?: Record<string, unknown>;
meta?: Record<string, string | number | boolean>;
}

export interface ProductCategory {
Expand Down

0 comments on commit ff1d9c0

Please sign in to comment.