Skip to content

Commit

Permalink
Surface our own in app message [sc-101965] (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
chayelheinsen authored Mar 15, 2024
1 parent 9934c39 commit fd992a0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
5 changes: 4 additions & 1 deletion android/src/main/java/com/rnmovableink/RNMovableInkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
14 changes: 13 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>
);
}
Expand Down
3 changes: 3 additions & 0 deletions ios/RNMovableInk.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions ios/RNMovableInk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
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 @@ -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"

Expand Down
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit fd992a0

Please sign in to comment.