diff --git a/.watchmanconfig b/.watchmanconfig new file mode 100644 index 00000000..d92d9876 --- /dev/null +++ b/.watchmanconfig @@ -0,0 +1,6 @@ +{ + "ignore_dirs": [ + ".git", + "node_modules" + ] +} diff --git a/android/build.gradle b/android/build.gradle index eb3e4370..d325d9e3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -3,6 +3,7 @@ buildscript { def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['GlassfyModule_kotlinVersion'] repositories { + mavenLocal() google() mavenCentral() } @@ -50,6 +51,7 @@ android { } repositories { + mavenLocal() mavenCentral() google() maven { @@ -127,6 +129,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion') dependencies { // noinspection GradleDynamicVersion api 'com.facebook.react:react-native:+' - implementation("io.glassfy:androidglue:1.3.7") + implementation("io.glassfy:androidglue:1.3.9") implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/android/src/main/java/com/reactnativeglassfymodule/GlassfyModuleModule.kt b/android/src/main/java/com/reactnativeglassfymodule/GlassfyModuleModule.kt index e898ac11..620b2680 100644 --- a/android/src/main/java/com/reactnativeglassfymodule/GlassfyModuleModule.kt +++ b/android/src/main/java/com/reactnativeglassfymodule/GlassfyModuleModule.kt @@ -4,8 +4,6 @@ import com.facebook.react.bridge.* import io.glassfy.glue.GlassfyGlue import org.json.JSONArray import org.json.JSONObject -import kotlin.reflect.typeOf - class GlassfyModuleModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { @@ -52,11 +50,13 @@ class GlassfyModuleModule(reactContext: ReactApplicationContext) : } @ReactMethod - fun initialize(apiKey: String, watcherMode: Boolean, promise: Promise) { + fun initialize(apiKey: String, watcherMode: Boolean, version: String, promise: Promise) { GlassfyGlue.initialize( this.reactApplicationContext, apiKey, - watcherMode + watcherMode, + "react-native", + version ) { value, error -> pluginCompletion(promise, value, error) } } @@ -76,6 +76,11 @@ class GlassfyModuleModule(reactContext: ReactApplicationContext) : GlassfyGlue.offerings { value, error -> pluginCompletion(promise, value, error) } } + @ReactMethod + fun purchaseHistory(promise: Promise) { + GlassfyGlue.purchaseHistory { value, error -> pluginCompletion(promise, value, error) } + } + @ReactMethod fun permissions(promise: Promise) { GlassfyGlue.permissions { value, error -> pluginCompletion(promise, value, error) } diff --git a/ios/GlassfyModule.m b/ios/GlassfyModule.m index 3df86396..dab0b9bd 100644 --- a/ios/GlassfyModule.m +++ b/ios/GlassfyModule.m @@ -20,17 +20,20 @@ @implementation GlassfyModule withRejecter:reject]]; } -RCT_REMAP_METHOD(initialize, initializeWithApiKey - : (NSString *)apiKey watcherMode - : (BOOL)watcherMode withResolver - : (RCTPromiseResolveBlock)resolve withRejecter - : (RCTPromiseRejectBlock)reject) { - - [GlassfyGlue - initializeWithApiKey:apiKey - watcherMode:watcherMode - withCompletion:[self responseFromGlassfyGluewithResolver:resolve - withRejecter:reject]]; +RCT_REMAP_METHOD( + initialize, + initializeWithApiKey: (NSString*)apiKey + watcherMode: (BOOL)watcherMode + version: (NSString*)version + withResolver: (RCTPromiseResolveBlock)resolve + withRejecter: (RCTPromiseRejectBlock)reject +) { + [GlassfyGlue initializeWithApiKey: apiKey + watcherMode: @(watcherMode) + crossPlatformSdkFramework: @"react-native" + crossPlatformSdkVersion: version + withCompletion:[self responseFromGlassfyGluewithResolver: resolve + withRejecter: reject]]; } RCT_REMAP_METHOD(setLogLevel, setLogLevel @@ -63,6 +66,16 @@ @implementation GlassfyModule withRejecter:reject]]; } +RCT_REMAP_METHOD(purchaseHistory, purchaseHistoryWithResolver + : (RCTPromiseResolveBlock)resolve withRejecter + : (RCTPromiseRejectBlock)reject) { + + [GlassfyGlue + purchaseHistoryWithCompletion:[self + responseFromGlassfyGluewithResolver:resolve + withRejecter:reject]]; +} + RCT_REMAP_METHOD(permissions, permissionsWithResolver : (RCTPromiseResolveBlock)resolve withRejecter : (RCTPromiseRejectBlock)reject) { diff --git a/package.json b/package.json index 8ca44c44..4510829f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-glassfy-module", - "version": "1.3.6", + "version": "1.3.7", "description": "glassfy module", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/react-native-glassfy-module.podspec b/react-native-glassfy-module.podspec index 7319e8b4..6f6fab36 100644 --- a/react-native-glassfy-module.podspec +++ b/react-native-glassfy-module.podspec @@ -16,5 +16,5 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,mm}" s.dependency "React-Core" - s.dependency "GlassfyGlue", "1.3.4" + s.dependency "GlassfyGlue", "1.3.5" end diff --git a/src/__tests__/index.test.tsx b/src/__tests__/index.test.tsx deleted file mode 100644 index bf84291a..00000000 --- a/src/__tests__/index.test.tsx +++ /dev/null @@ -1 +0,0 @@ -it.todo('write a test'); diff --git a/src/index.tsx b/src/index.tsx index 77747b53..c67963c1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,11 +6,28 @@ export enum GLASSFY_ELEGGIBILITY { UNKNOWN = 0, } +export enum GLASSFY_EVENT_TYPE { + InitialBuy = 5001, + Restarted = 5002, + Renewed = 5003, + Expired = 5004, + DidChangeRenewalStatus = 5005, + IsInBillingRetryPeriod = 5006, + ProductChange = 5007, + InAppPurchase = 5008, + Refund = 5009, + Paused = 5010, + Resumed = 5011, + ConnectLicense = 5012, + DisconnectLicense = 5013 +} + export enum GLASSFY_STORE { AppStore = 1, PlayStore = 2, Paddle = 3, } + export enum GLASSFY_LOGLEVEL { OFF = 0, ERROR = 1, @@ -112,6 +129,29 @@ export interface GlassfyOffering { export interface GlassfyOfferings { readonly all: GlassfyOffering[]; } + +export interface GlassfyPurchasesHistory { + readonly all: GlassfyPurchaseHistory[]; +} + +export interface GlassfyPurchaseHistory { + readonly productId: string; + readonly skuId: string; + readonly type: GLASSFY_EVENT_TYPE + readonly store: GLASSFY_STORE; + readonly purchaseDate: string; + readonly expireDate: string; + readonly transactionId: string; + readonly subscriberId: string; + readonly currencyCode: string; + readonly countryCode: string; + readonly isInIntroOfferPeriod: boolean; + readonly promotionalOfferId: string; + readonly offerCodeRefName: string; + readonly licenseCode: string; + readonly webOrderLineItemId: string; +} + export interface GlassfyPermission { readonly permissionId: string; readonly entitlement: GLASSFY_ENTITLEMENT; @@ -181,16 +221,19 @@ export class Glassfy { public static async sdkVersion(): Promise { return GlassfyModule.sdkVersion(); } + public static async initialize( apiKey: string, watcherMode: boolean ): Promise { - return GlassfyModule.initialize(apiKey, watcherMode); + const version = '1.3.7'; + return GlassfyModule.initialize(apiKey, watcherMode, version); } public static async setLogLevel(level: GLASSFY_LOGLEVEL): Promise { return GlassfyModule.setLogLevel(level); } + public static async presentAppStoreCodeRedemptionSheet(): Promise { return GlassfyModule.presentAppStoreCodeRedemptionSheet(); } @@ -199,20 +242,23 @@ export class Glassfy { return GlassfyModule.offerings(); } + public static async purchaseHistory(): Promise { + return GlassfyModule.purchaseHistory(); + } + public static async permissions(): Promise { return GlassfyModule.permissions(); } + public static async skuWithId(identifier: string): Promise { - let sku = GlassfyModule.skuWithId(identifier); - return sku; + return GlassfyModule.skuWithId(identifier); } public static async skuWithIdAndStore( identifier: string, store: GLASSFY_STORE ): Promise { - let sku = GlassfyModule.skuWithIdAndStore(identifier, store); - return sku; + return GlassfyModule.skuWithIdAndStore(identifier, store); } public static async connectCustomSubscriber( @@ -228,10 +274,10 @@ export class Glassfy { return GlassfyModule.connectPaddleLicenseKey(licenseKey, force ? 1 : 0); } - public static async setEmailUserProperty(email: string): Promise { - let sku = GlassfyModule.setEmailUserProperty(email); - return sku; + public static async setEmailUserProperty(email: string): Promise { + return GlassfyModule.setEmailUserProperty(email); } + public static async setExtraUserProperty( extraProp: GlassfyExtraProperty ): Promise { @@ -239,8 +285,7 @@ export class Glassfy { } public static async getUserProperties(): Promise { - let userProp = GlassfyModule.getUserProperties(); - return userProp; + return GlassfyModule.getUserProperties(); } public static async purchaseSku( diff --git a/yarn.lock b/yarn.lock index 46df6ce3..e4fc8575 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1609,7 +1609,7 @@ "@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/trace-mapping" "^0.3.9" -"@jridgewell/resolve-uri@3.1.0", "@jridgewell/resolve-uri@^3.0.3": +"@jridgewell/resolve-uri@3.1.0": version "3.1.0" resolved "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz" integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== @@ -1624,22 +1624,14 @@ resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== -"@jridgewell/trace-mapping@^0.3.15": - version "0.3.16" - resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.16.tgz" - integrity sha512-LCQ+NeThyJ4k1W2d+vIKdxuSt9R3pQSZ4P92m7EakaYuXcVWbHuT5bjNcqLd4Rdgi6xYWYDvBJZJLZSLanjDcA== +"@jridgewell/trace-mapping@^0.3.15", "@jridgewell/trace-mapping@^0.3.9": + version "0.3.17" + resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz" + integrity sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g== dependencies: "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" -"@jridgewell/trace-mapping@^0.3.9": - version "0.3.15" - resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.15.tgz" - integrity sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz"