From 375e142e67edfae7d2389a45de91a29598756cfc Mon Sep 17 00:00:00 2001 From: glassfy-robot Date: Mon, 28 Feb 2022 15:42:46 +0000 Subject: [PATCH] (a4dae62d) --- .eslintignore | 1 + README.md | 28 ++++++++++--------- example/angular.json | 7 +---- example/ios/App/App.xcodeproj/project.pbxproj | 4 +-- example/src/app/home/home.page.ts | 22 +++++++++++---- example/tsconfig.app.json | 13 ++++----- example/tsconfig.json | 4 ++- ios/Plugin/GlassfyPlugin.swift | 6 +--- package.json | 2 +- src/definitions.ts | 11 ++++---- src/web.ts | 4 +-- tsconfig.json | 4 ++- 12 files changed, 56 insertions(+), 50 deletions(-) diff --git a/.eslintignore b/.eslintignore index 9d0b71a..18b63ae 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ build dist +example \ No newline at end of file diff --git a/README.md b/README.md index dd23743..5a43e86 100644 --- a/README.md +++ b/README.md @@ -202,12 +202,12 @@ setDeviceToken(options: { token: string; }) => Promise ### setExtraUserProperty(...) ```typescript -setExtraUserProperty(options: { extraProperty: [string: any]; }) => Promise +setExtraUserProperty(options: { extra: { [key: string]: any; }; }) => Promise ``` -| Param | Type | -| ------------- | ---------------------------------------------- | -| **`options`** | { extraProperty: [string: any]; } | +| Param | Type | +| ------------- | ------------------------------------------------ | +| **`options`** | { extra: { [key: string]: any; }; } | -------------------- @@ -215,9 +215,11 @@ setExtraUserProperty(options: { extraProperty: [string: any]; }) => Promise Promise +getUserProperty() => Promise<{ extra: { [key: string]: any; }; }> ``` +**Returns:** Promise<{ extra: { [key: string]: any; }; }> + -------------------- @@ -248,13 +250,13 @@ getUserProperty() => Promise #### GlassfySku -| Prop | Type | -| ----------------------------- | --------------------------------------------------------------------- | -| **`skuId`** | string | -| **`productId`** | string | -| **`introductoryEligibility`** | GLASSFY_ELEGGIBILITY | -| **`promotionalEligibility`** | GLASSFY_ELEGGIBILITY | -| **`extravars`** | { [key: string]: string; } | +| Prop | Type | +| ----------------------------- | ------------------------------------------------------------------- | +| **`skuId`** | string | +| **`productId`** | string | +| **`introductoryEligibility`** | GLASSFY_ELIGIBILITY | +| **`promotionalEligibility`** | GLASSFY_ELIGIBILITY | +| **`extravars`** | { [key: string]: string; } | #### GlassfyPermissions @@ -291,7 +293,7 @@ getUserProperty() => Promise ### Enums -#### GLASSFY_ELEGGIBILITY +#### GLASSFY_ELIGIBILITY | Members | Value | | ------------------ | --------------- | diff --git a/example/angular.json b/example/angular.json index c6da09d..3edaada 100644 --- a/example/angular.json +++ b/example/angular.json @@ -49,14 +49,12 @@ "with": "src/environments/environment.prod.ts" } ], - "optimization": true, "outputHashing": "all", "sourceMap": false, "namedChunks": false, "aot": true, "extractLicenses": true, "vendorChunk": false, - "buildOptimizer": true, "budgets": [ { "type": "initial", @@ -122,10 +120,7 @@ "lint": { "builder": "@angular-eslint/builder:lint", "options": { - "lintFilePatterns": [ - "src/**/*.ts", - "src/**/*.html" - ] + "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] } }, "e2e": { diff --git a/example/ios/App/App.xcodeproj/project.pbxproj b/example/ios/App/App.xcodeproj/project.pbxproj index b8e3c9a..6816f8e 100644 --- a/example/ios/App/App.xcodeproj/project.pbxproj +++ b/example/ios/App/App.xcodeproj/project.pbxproj @@ -350,7 +350,7 @@ INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.1.80; + MARKETING_VERSION = 1.1.81; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = app.example.app; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -370,7 +370,7 @@ INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.1.80; + MARKETING_VERSION = 1.1.81; PRODUCT_BUNDLE_IDENTIFIER = app.example.app; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; diff --git a/example/src/app/home/home.page.ts b/example/src/app/home/home.page.ts index cf10c73..2143657 100644 --- a/example/src/app/home/home.page.ts +++ b/example/src/app/home/home.page.ts @@ -1,6 +1,6 @@ import { AfterViewInit, Component } from '@angular/core'; import { AlertController } from '@ionic/angular'; -import { Glassfy, GlassfyOfferings, GlassfyOffering, GlassfySku } from 'capacitor-plugin-glassfy'; +import { Glassfy, GlassfyOfferings, GlassfyOffering } from 'capacitor-plugin-glassfy'; @Component({ selector: 'app-home', @@ -36,7 +36,16 @@ export class HomePage implements AfterViewInit { await Glassfy.initialize({ apiKey: "my_api_key", watcherMode: false }); - } catch (err) { + await Glassfy.setExtraUserProperty({ extra: { "key1": "value1" } }); + + let extra = await Glassfy.getUserProperty(); + + console.log("Extra " + extra); + + } catch (error) { + let message = 'Unknown Error' + if (error instanceof Error) message = error.message + await this.presentAlert(message); } } @@ -58,11 +67,14 @@ export class HomePage implements AfterViewInit { this.presentAlert(JSON.stringify(transaction)) - } catch (e) { + } catch (error) { + let message = 'Unknown Error' + if (error instanceof Error) message = error.message + console.log('##############################################') - console.log(e) + console.log(message) console.log('##############################################') - await this.presentAlert(e); + await this.presentAlert(message); } this.processing = false diff --git a/example/tsconfig.app.json b/example/tsconfig.app.json index 82d91dc..33aff31 100644 --- a/example/tsconfig.app.json +++ b/example/tsconfig.app.json @@ -3,13 +3,10 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./out-tsc/app", - "types": [] + "types": [], + "forceConsistentCasingInFileNames": true, + "strict": true }, - "files": [ - "src/main.ts", - "src/polyfills.ts" - ], - "include": [ - "src/**/*.d.ts" - ] + "files": ["src/main.ts", "src/polyfills.ts"], + "include": ["src/**/*.d.ts"] } diff --git a/example/tsconfig.json b/example/tsconfig.json index 5acda4a..33dc971 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -12,7 +12,9 @@ "importHelpers": true, "target": "es2015", "module": "es2020", - "lib": ["es2018", "dom"] + "lib": ["es2018", "dom"], + "forceConsistentCasingInFileNames": true, + "strict": true }, "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false, diff --git a/ios/Plugin/GlassfyPlugin.swift b/ios/Plugin/GlassfyPlugin.swift index 0cbe5f4..b154519 100644 --- a/ios/Plugin/GlassfyPlugin.swift +++ b/ios/Plugin/GlassfyPlugin.swift @@ -138,7 +138,6 @@ public class GlassfyPlugin: CAPPlugin { if let ll = Glassfy.LogLevel(rawValue: UInt(logLevel)) { Glassfy.log(level: ll) } - call.resolve() } @objc func setDeviceToken(_ call: CAPPluginCall) { @@ -154,7 +153,6 @@ public class GlassfyPlugin: CAPPlugin { } call.resolve() } - call.resolve() } @@ -171,10 +169,9 @@ public class GlassfyPlugin: CAPPlugin { } call.resolve() } - call.resolve() } - @objc func getExtraUserProperty(_ call: CAPPluginCall) { + @objc func getUserProperty(_ call: CAPPluginCall) { GlassfyGlue.getExtraUserProperty() { extra, error in if let error = error { @@ -185,6 +182,5 @@ public class GlassfyPlugin: CAPPlugin { call.resolve(extra) } } - call.resolve() } } diff --git a/package.json b/package.json index c7b68b8..7d19a15 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "capacitor-plugin-glassfy", - "version": "1.1.80", + "version": "1.1.81", "description": "Glassfy Plugin", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js", diff --git a/src/definitions.ts b/src/definitions.ts index 0939ea5..6c07a79 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -1,4 +1,4 @@ -export enum GLASSFY_ELEGGIBILITY { +export enum GLASSFY_ELIGIBILITY { ELEGIBLE = 1, NON_ELEGIBLE = -1, UNKNOWN = 0, @@ -60,8 +60,8 @@ export interface GlassfyVersion { export interface GlassfySku { readonly skuId: string; readonly productId: string; - readonly introductoryEligibility: GLASSFY_ELEGGIBILITY; - readonly promotionalEligibility: GLASSFY_ELEGGIBILITY; + readonly introductoryEligibility: GLASSFY_ELIGIBILITY; + readonly promotionalEligibility: GLASSFY_ELIGIBILITY; readonly extravars: { [key: string]: string }; } @@ -96,7 +96,6 @@ export interface GlassfyTransaction { readonly permissions: GlassfyPermissions; } - export interface GlassfyPlugin { sdkVersion(): Promise; @@ -133,8 +132,8 @@ export interface GlassfyPlugin { setDeviceToken(options: { token: string }): Promise; - setExtraUserProperty(options: { extraProperty: [string: any] }): Promise; + setExtraUserProperty(options: { extra: { [key: string]: any } }): Promise; - getUserProperty(): Promise; + getUserProperty(): Promise<{ extra: { [key: string]: any } }>; } diff --git a/src/web.ts b/src/web.ts index 4d64c06..0606163 100644 --- a/src/web.ts +++ b/src/web.ts @@ -56,12 +56,12 @@ export class GlassfyWeb extends WebPlugin implements GlassfyPlugin { throw this.unimplemented('Not supported on web.'); } - async setExtraUserProperty(options: { extraProperty: [string: any] }): Promise { + async setExtraUserProperty(options: { extra: { [key: string]: any } }): Promise { console.log(options); throw this.unimplemented('Not supported on web.'); } - async getUserProperty(): Promise { + async getUserProperty(): Promise<{ extra: { [key: string]: any } }> { throw this.unimplemented('Not supported on web.'); } diff --git a/tsconfig.json b/tsconfig.json index f2e88e6..ae8fb62 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,9 @@ "pretty": true, "sourceMap": true, "strict": true, - "target": "es2017" + "target": "es2017", + "forceConsistentCasingInFileNames": true, + "importHelpers": true }, "files": ["src/index.ts"] }