Skip to content
Merged
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 Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PackageDescription

let package = Package(
name: "QonversionCapacitor",
platforms: [.iOS(.v13)],
platforms: [.iOS(.v14)],
products: [
.library(
name: "QonversionCapacitor",
Expand Down
4 changes: 2 additions & 2 deletions QonversionCapacitorPlugin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Pod::Spec.new do |s|
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '13.0'
s.ios.deployment_target = '14.0'
s.dependency 'Capacitor'
s.swift_version = '5.1'
s.dependency "QonversionSandwich", "5.2.1"
s.dependency "QonversionSandwich", "7.3.1"
end
16 changes: 8 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ext {

buildscript {
ext {
kotlin_version = '2.0.20'
kotlin_version = '2.1.0'
}
repositories {
google()
Expand All @@ -24,10 +24,10 @@ apply plugin: 'org.jetbrains.kotlin.android'

android {
namespace "io.qonversion.capacitor"
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -42,11 +42,11 @@ android {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
kotlinOptions {
jvmTarget = '17'
jvmTarget = '21'
}
}

Expand All @@ -61,7 +61,7 @@ dependencies {
implementation project(':capacitor-android')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation 'androidx.core:core-ktx:1.13.1'
implementation "io.qonversion:sandwich:5.2.1"
implementation "io.qonversion:sandwich:7.3.1"
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
Expand Down
135 changes: 135 additions & 0 deletions android/src/main/java/io/qonversion/capacitor/NoCodesPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package io.qonversion.capacitor

import android.app.Activity
import android.app.Application
import com.getcapacitor.JSObject
import com.getcapacitor.Plugin
import com.getcapacitor.PluginCall
import com.getcapacitor.PluginMethod
import com.getcapacitor.annotation.CapacitorPlugin
import io.qonversion.sandwich.ActivityProvider
import io.qonversion.sandwich.BridgeData
import io.qonversion.sandwich.NoCodesEventListener
import io.qonversion.sandwich.NoCodesPurchaseDelegateBridge
import io.qonversion.sandwich.NoCodesSandwich

private const val NoCodesEventName = "noCodesEvent"
private const val NoCodesPurchaseEventName = "noCodesPurchase"
private const val NoCodesRestoreEventName = "noCodesRestore"

@CapacitorPlugin(name = "NoCodes")
class NoCodesPlugin : Plugin() {
private val noCodesSandwich by lazy {
NoCodesSandwich()
}

private val noCodesEventListener = object : NoCodesEventListener {
override fun onNoCodesEvent(event: NoCodesEventListener.Event, payload: BridgeData?) {
val eventData = JSObject().apply {
put("name", event.key)
put("payload", payload?.toJSObject() ?: JSObject())
}
notifyListeners(NoCodesEventName, eventData)
}
}

private val purchaseDelegateBridge = object : NoCodesPurchaseDelegateBridge {
override fun purchase(product: BridgeData) {
notifyListeners(NoCodesPurchaseEventName, product.toJSObject())
}

override fun restore() {
notifyListeners(NoCodesRestoreEventName, JSObject())
}
}

@PluginMethod
fun initialize(call: PluginCall) {
val context = context?.applicationContext
?: return call.reject("Can't get application context for NoCodes initialization", "InitializationError")
val projectKey = call.getString("projectKey")
?: return call.noNecessaryDataError("projectKey")

val proxyUrl = call.getString("proxyUrl")
val locale = call.getString("locale")

noCodesSandwich.initialize(context, projectKey, proxyUrl, locale = locale)
noCodesSandwich.setDelegate(noCodesEventListener)

val source = call.getString("source")
val version = call.getString("version")
if (source != null && version != null) {
noCodesSandwich.storeSdkInfo(context, source, version)
}

call.resolve()
}

@PluginMethod
fun setScreenPresentationConfig(call: PluginCall) {
val configData = call.getObject("configData")?.toMap()
?: return call.noNecessaryDataError("configData")
val contextKey = call.getString("contextKey")

noCodesSandwich.setScreenPresentationConfig(configData, contextKey)
call.resolve()
}

@PluginMethod
fun showScreen(call: PluginCall) {
val contextKey = call.getString("contextKey")
?: return call.noNecessaryDataError("contextKey")

noCodesSandwich.showScreen(contextKey)
call.resolve()
}

@PluginMethod
fun close(call: PluginCall) {
noCodesSandwich.close()
call.resolve()
}

@PluginMethod
fun setLocale(call: PluginCall) {
val locale = call.getString("locale")
noCodesSandwich.setLocale(locale)
call.resolve()
}

@PluginMethod
fun setPurchaseDelegate(call: PluginCall) {
noCodesSandwich.setPurchaseDelegate(purchaseDelegateBridge)
call.resolve()
}

@PluginMethod
fun delegatedPurchaseCompleted(call: PluginCall) {
noCodesSandwich.delegatedPurchaseCompleted()
call.resolve()
}

@PluginMethod
fun delegatedPurchaseFailed(call: PluginCall) {
val errorMessage = call.getString("errorMessage")
?: return call.noNecessaryDataError("errorMessage")

noCodesSandwich.delegatedPurchaseFailed(errorMessage)
call.resolve()
}

@PluginMethod
fun delegatedRestoreCompleted(call: PluginCall) {
noCodesSandwich.delegatedRestoreCompleted()
call.resolve()
}

@PluginMethod
fun delegatedRestoreFailed(call: PluginCall) {
val errorMessage = call.getString("errorMessage")
?: return call.noNecessaryDataError("errorMessage")

noCodesSandwich.delegatedRestoreFailed(errorMessage)
call.resolve()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class QonversionPlugin : Plugin() {
val updatePolicyKey = call.getString("updatePolicyKey")
val contextKeys = call.getArray("contextKeys")?.toList<String>()

qonversionSandwich.purchase(
qonversionSandwich.purchaseWithResult(
productId,
offerId,
applyOffer,
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apply plugin: 'com.android.application'

android {
namespace "com.qonversion.sample"
namespace "io.qonversion.sampleapp"
compileSdk rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.qonversion.sample"
applicationId "io.qonversion.sampleapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.qonversion.sample;
package io.qonversion.sampleapp;

import com.getcapacitor.BridgeActivity;

Expand Down
2 changes: 1 addition & 1 deletion example/android/variables.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ext {
minSdkVersion = 22
minSdkVersion = 23
compileSdkVersion = 35
targetSdkVersion = 35
androidxActivityVersion = '1.8.0'
Expand Down
20 changes: 10 additions & 10 deletions example/ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ PODS:
- CapacitorCordova (7.3.0)
- CapacitorSplashScreen (7.0.1):
- Capacitor
- Qonversion (5.13.4):
- Qonversion/Main (= 5.13.4)
- Qonversion/Main (5.13.4)
- Qonversion (6.3.1):
- Qonversion/Main (= 6.3.1)
- Qonversion/Main (6.3.1)
- QonversionCapacitorPlugin (0.3.1):
- Capacitor
- QonversionSandwich (= 5.2.1)
- QonversionSandwich (5.2.1):
- Qonversion (= 5.13.4)
- QonversionSandwich (= 7.3.1)
- QonversionSandwich (7.3.1):
- Qonversion (= 6.3.1)

DEPENDENCIES:
- "Capacitor (from `../../node_modules/@capacitor/ios`)"
Expand Down Expand Up @@ -44,10 +44,10 @@ SPEC CHECKSUMS:
CapacitorCamera: eb8687d8687fed853598ec9460d94bcd5e16babe
CapacitorCordova: 2685f5c43675793b5f06dfd66b3b26268f003b97
CapacitorSplashScreen: 19cd3573e57507e02d6f34597a8c421e00931487
Qonversion: 40c22c4da4aa07f999115f6bf7ce4abaf3f4a90b
QonversionCapacitorPlugin: 1d42e7b6fa204f8c7614065b704cd258bde5ebb6
QonversionSandwich: 36e19e9c7c2016b2b12ade6660fa6d0b25539775
Qonversion: 48d745b4ada2b50c57bf58d82c14822675ef3535
QonversionCapacitorPlugin: 79081868e54201f0319bdd66575f6ae136a2f44e
QonversionSandwich: d3e6fd4882ac0778b8e9708248117d36a51000c0

PODFILE CHECKSUM: afe3f9454c98dc22ff3619593d5dcbd43e1499e8

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
13 changes: 7 additions & 6 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
"refresh": "cd .. && yarn build && cd example && yarn clean"
},
"dependencies": {
"@capacitor/android": "^7.2.0",
"@capacitor/camera": "^7.0.1",
"@capacitor/core": "^7.2.0",
"@capacitor/ios": "^7.2.0",
"@capacitor/splash-screen": "^7.0.1",
"@capacitor/android": "^8.0.0",
"@capacitor/camera": "^8.0.0",
"@capacitor/core": "^8.0.0",
"@capacitor/ios": "^8.0.0",
"@capacitor/splash-screen": "^8.0.0",
"@qonversion/capacitor-plugin": "file:.."
},
"devDependencies": {
"@capacitor/cli": "^7.2.0",
"@capacitor/cli": "^8.0.0",
"typescript": "^5.3.0",
"vite": "^5.4.2"
},
"author": "",
Expand Down
Loading