Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from glassfy/purchase-history
Browse files Browse the repository at this point in the history
Added Purchase history, sdk init parms
  • Loading branch information
lgarbo authored Mar 31, 2023
2 parents e1edecf + 878b959 commit 66095c3
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 42 deletions.
6 changes: 6 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ignore_dirs": [
".git",
"node_modules"
]
}
4 changes: 3 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ buildscript {
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['GlassfyModule_kotlinVersion']

repositories {
mavenLocal()
google()
mavenCentral()
}
Expand Down Expand Up @@ -50,6 +51,7 @@ android {
}

repositories {
mavenLocal()
mavenCentral()
google()
maven {
Expand Down Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) }
}

Expand All @@ -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) }
Expand Down
35 changes: 24 additions & 11 deletions ios/GlassfyModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion react-native-glassfy-module.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion src/__tests__/index.test.tsx

This file was deleted.

65 changes: 55 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -181,16 +221,19 @@ export class Glassfy {
public static async sdkVersion(): Promise<GlassfyVersion> {
return GlassfyModule.sdkVersion();
}

public static async initialize(
apiKey: string,
watcherMode: boolean
): Promise<void> {
return GlassfyModule.initialize(apiKey, watcherMode);
const version = '1.3.7';
return GlassfyModule.initialize(apiKey, watcherMode, version);
}

public static async setLogLevel(level: GLASSFY_LOGLEVEL): Promise<void> {
return GlassfyModule.setLogLevel(level);
}

public static async presentAppStoreCodeRedemptionSheet(): Promise<void> {
return GlassfyModule.presentAppStoreCodeRedemptionSheet();
}
Expand All @@ -199,20 +242,23 @@ export class Glassfy {
return GlassfyModule.offerings();
}

public static async purchaseHistory(): Promise<GlassfyPurchasesHistory> {
return GlassfyModule.purchaseHistory();
}

public static async permissions(): Promise<GlassfyPermissions> {
return GlassfyModule.permissions();
}

public static async skuWithId(identifier: string): Promise<GlassfySku> {
let sku = GlassfyModule.skuWithId(identifier);
return sku;
return GlassfyModule.skuWithId(identifier);
}

public static async skuWithIdAndStore(
identifier: string,
store: GLASSFY_STORE
): Promise<GlassfySkuBase> {
let sku = GlassfyModule.skuWithIdAndStore(identifier, store);
return sku;
return GlassfyModule.skuWithIdAndStore(identifier, store);
}

public static async connectCustomSubscriber(
Expand All @@ -228,19 +274,18 @@ export class Glassfy {
return GlassfyModule.connectPaddleLicenseKey(licenseKey, force ? 1 : 0);
}

public static async setEmailUserProperty(email: string): Promise<GlassfySku> {
let sku = GlassfyModule.setEmailUserProperty(email);
return sku;
public static async setEmailUserProperty(email: string): Promise<void> {
return GlassfyModule.setEmailUserProperty(email);
}

public static async setExtraUserProperty(
extraProp: GlassfyExtraProperty
): Promise<void> {
return GlassfyModule.setExtraUserProperty(extraProp);
}

public static async getUserProperties(): Promise<GlassfyUserProperties> {
let userProp = GlassfyModule.getUserProperties();
return userProp;
return GlassfyModule.getUserProperties();
}

public static async purchaseSku(
Expand Down
18 changes: 5 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@
"@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/trace-mapping" "^0.3.9"

"@jridgewell/[email protected]", "@jridgewell/resolve-uri@^3.0.3":
"@jridgewell/[email protected]":
version "3.1.0"
resolved "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz"
integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
Expand All @@ -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/[email protected]":
version "2.1.5"
resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz"
Expand Down

0 comments on commit 66095c3

Please sign in to comment.