From fd992a0e9571b209192c5bcbfb9fbc3d23edec75 Mon Sep 17 00:00:00 2001 From: Chayel J Heinsen <chayelheinsen@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:28:44 -0400 Subject: [PATCH] Surface our own in app message [sc-101965] (#9) --- .../java/com/rnmovableink/RNMovableInkModule.kt | 5 ++++- example/src/App.tsx | 14 +++++++++++++- ios/RNMovableInk.m | 3 +++ ios/RNMovableInk.swift | 7 +++++++ react-native-movable-ink.podspec | 2 +- src/index.tsx | 1 + 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/rnmovableink/RNMovableInkModule.kt b/android/src/main/java/com/rnmovableink/RNMovableInkModule.kt index 38c9b11..01fdcc1 100644 --- a/android/src/main/java/com/rnmovableink/RNMovableInkModule.kt +++ b/android/src/main/java/com/rnmovableink/RNMovableInkModule.kt @@ -57,16 +57,19 @@ class RNMovableInkModule(reactContext: ReactApplicationContext) : fun categoryViewed(properties: ReadableMap) { MIClient.categoryViewed(properties.toHashMap()) } + @ReactMethod fun productRemoved(properties: ReadableMap) { MIClient.productRemoved(properties.toHashMap()) } + @ReactMethod fun logEvent(name: String, properties: ReadableMap) { MIClient.logEvent(name, properties.toHashMap()) } + @ReactMethod - fun checkPasteboardOnInstall( promise: Promise) { + fun checkPasteboardOnInstall(promise: Promise) { MIClient.checkPasteboardOnInstall { resolved -> promise.resolve(resolved) } diff --git a/example/src/App.tsx b/example/src/App.tsx index 45417c6..735822e 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -6,7 +6,7 @@ export default function App() { const [link, setLink] = React.useState<string | undefined>(); React.useEffect(() => { - // Make sure to call RNMovableInk.start when your app start + // Make sure to call RNMovableInk.start when your app starts RNMovableInk.start(); // Get the deep link used to open the app @@ -59,6 +59,18 @@ export default function App() { RNMovableInk.productSearched({ query: 'Test Event' }); }} /> + + <Button + title="Show In App Message" + onPress={(_event) => { + RNMovableInk.showInAppMessage( + 'https://www.movable-ink-7158.com/p/rp/bc49c08945403625.html', + (buttonID) => { + console.log(buttonID); + } + ); + }} + /> </View> ); } diff --git a/ios/RNMovableInk.m b/ios/RNMovableInk.m index 23ed1c9..874cd04 100644 --- a/ios/RNMovableInk.m +++ b/ios/RNMovableInk.m @@ -20,6 +20,9 @@ @interface RCT_EXTERN_MODULE(RNMovableInk, NSObject) RCT_EXTERN_METHOD(checkPasteboardOnInstall:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject) +RCT_EXTERN_METHOD(showInAppMessage:(NSString *)link withCallback:(RCTResponseSenderBlock)callback) + + + (BOOL)requiresMainQueueSetup { return TRUE; } diff --git a/ios/RNMovableInk.swift b/ios/RNMovableInk.swift index 000e99a..0f96a14 100644 --- a/ios/RNMovableInk.swift +++ b/ios/RNMovableInk.swift @@ -61,6 +61,13 @@ public class RNMovableInk: NSObject { resolve(value?.absoluteString) } } + + @objc(showInAppMessage:withCallback:) + public func showInAppMessage(link: String, callback: @escaping RCTResponseSenderBlock) { + MIClient.showInAppMessage(with: link) { buttonID in + callback([buttonID]) + } + } @objc(productSearched:) public func productSearched(properties: [String: Any]) { diff --git a/react-native-movable-ink.podspec b/react-native-movable-ink.podspec index 6a5b1ab..5757264 100644 --- a/react-native-movable-ink.podspec +++ b/react-native-movable-ink.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/movableink/mobile-sdk-react-native.git", :tag => "#{s.version}" } s.source_files = "ios/**/*.{h,m,mm,swift}" - + s.dependency 'MovableInk', '1.5.0' s.dependency "React-Core" diff --git a/src/index.tsx b/src/index.tsx index 9dc834b..6b1387d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -48,6 +48,7 @@ export interface MovableInkInterface { identifyUser(): void; setMIU(value: string): void; checkPasteboardOnInstall(): Promise<string | null>; + showInAppMessage(url: string, callback: (buttonID: string) => void): void; } export default RNMovableInk as MovableInkInterface;