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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ android {
}

dependencies {
implementation "com.superwall.sdk:superwall-android:2.6.1"
implementation "com.superwall.sdk:superwall-android:2.6.2"
implementation 'com.android.billingclient:billing:8.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -402,5 +402,20 @@ class SuperwallExpoModule : Module() {
Superwall.instance.logLevel = logLevel
}
}

AsyncFunction("consume") { purchaseToken, promise: Promise ->
ioScope.launch {
Superwall.instance.consume(purchaseToken)
.fold({ result ->
scope.launch {
promise.resolve(result)
}
}, { error ->
scope.launch {
promise.reject(CodedException(error))
}
})
}
}
}
}
2 changes: 2 additions & 0 deletions src/SuperwallExpoModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ declare class SuperwallExpoModule extends NativeModule<SuperwallExpoModuleEvents
preloadPaywalls(placementNames: string[]): void
preloadAllPaywalls(): void

consume(purchaseToken: string): Promise<string>

setLogLevel(level: string): void
}

Expand Down
12 changes: 12 additions & 0 deletions src/compat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,18 @@ export default class Superwall {
await SuperwallExpoModule.preloadPaywalls(Array.from(placementNames))
}

/**
* Initiates a consumption of an In-App product.
*
* Use this function to consume an In-App product after processing it in your application.
*
* @param {string} purchaseToken - The token related to the purchase you wish to consume.
* @return {Promise<string>} Containing the consumed token, or an error.
*/
async consume(purchaseToken: string): Promise<string> {
return await SuperwallExpoModule.consume(purchaseToken)
}

/**
* Sets user attributes for use in paywalls and on the Superwall dashboard.
*
Expand Down
3 changes: 3 additions & 0 deletions src/useSuperwall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ export const useSuperwallStore = create<SuperwallStore>((set, get) => ({
const attributes = await SuperwallExpoModule.getDeviceAttributes()
return attributes
},
consume: async (purchaseToken: string) => {
return await SuperwallExpoModule.consume(purchaseToken)
},

/* -------------------- Listener helpers -------------------- */
_initListeners: (): (() => void) => {
Expand Down
Loading