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

Commit

Permalink
(a4dae62d)
Browse files Browse the repository at this point in the history
  • Loading branch information
glassfy-robot committed Feb 28, 2022
1 parent e05c30e commit 375e142
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 50 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
dist
example
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,24 @@ setDeviceToken(options: { token: string; }) => Promise<void>
### setExtraUserProperty(...)

```typescript
setExtraUserProperty(options: { extraProperty: [string: any]; }) => Promise<void>
setExtraUserProperty(options: { extra: { [key: string]: any; }; }) => Promise<void>
```

| Param | Type |
| ------------- | ---------------------------------------------- |
| **`options`** | <code>{ extraProperty: [string: any]; }</code> |
| Param | Type |
| ------------- | ------------------------------------------------ |
| **`options`** | <code>{ extra: { [key: string]: any; }; }</code> |

--------------------


### getUserProperty()

```typescript
getUserProperty() => Promise<void>
getUserProperty() => Promise<{ extra: { [key: string]: any; }; }>
```

**Returns:** <code>Promise&lt;{ extra: { [key: string]: any; }; }&gt;</code>

--------------------


Expand Down Expand Up @@ -248,13 +250,13 @@ getUserProperty() => Promise<void>

#### GlassfySku

| Prop | Type |
| ----------------------------- | --------------------------------------------------------------------- |
| **`skuId`** | <code>string</code> |
| **`productId`** | <code>string</code> |
| **`introductoryEligibility`** | <code><a href="#glassfy_eleggibility">GLASSFY_ELEGGIBILITY</a></code> |
| **`promotionalEligibility`** | <code><a href="#glassfy_eleggibility">GLASSFY_ELEGGIBILITY</a></code> |
| **`extravars`** | <code>{ [key: string]: string; }</code> |
| Prop | Type |
| ----------------------------- | ------------------------------------------------------------------- |
| **`skuId`** | <code>string</code> |
| **`productId`** | <code>string</code> |
| **`introductoryEligibility`** | <code><a href="#glassfy_eligibility">GLASSFY_ELIGIBILITY</a></code> |
| **`promotionalEligibility`** | <code><a href="#glassfy_eligibility">GLASSFY_ELIGIBILITY</a></code> |
| **`extravars`** | <code>{ [key: string]: string; }</code> |


#### GlassfyPermissions
Expand Down Expand Up @@ -291,7 +293,7 @@ getUserProperty() => Promise<void>
### Enums


#### GLASSFY_ELEGGIBILITY
#### GLASSFY_ELIGIBILITY

| Members | Value |
| ------------------ | --------------- |
Expand Down
7 changes: 1 addition & 6 deletions example/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -122,10 +120,7 @@
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
}
},
"e2e": {
Expand Down
4 changes: 2 additions & 2 deletions example/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
Expand All @@ -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 = "";
Expand Down
22 changes: 17 additions & 5 deletions example/src/app/home/home.page.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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);

}
}
Expand All @@ -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

Expand Down
13 changes: 5 additions & 8 deletions example/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
4 changes: 3 additions & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": ["es2018", "dom"]
"lib": ["es2018", "dom"],
"forceConsistentCasingInFileNames": true,
"strict": true
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
Expand Down
6 changes: 1 addition & 5 deletions ios/Plugin/GlassfyPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -154,7 +153,6 @@ public class GlassfyPlugin: CAPPlugin {
}
call.resolve()
}
call.resolve()
}


Expand All @@ -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 {
Expand All @@ -185,6 +182,5 @@ public class GlassfyPlugin: CAPPlugin {
call.resolve(extra)
}
}
call.resolve()
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 5 additions & 6 deletions src/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum GLASSFY_ELEGGIBILITY {
export enum GLASSFY_ELIGIBILITY {
ELEGIBLE = 1,
NON_ELEGIBLE = -1,
UNKNOWN = 0,
Expand Down Expand Up @@ -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 };
}

Expand Down Expand Up @@ -96,7 +96,6 @@ export interface GlassfyTransaction {
readonly permissions: GlassfyPermissions;
}


export interface GlassfyPlugin {
sdkVersion(): Promise<GlassfyVersion>;

Expand Down Expand Up @@ -133,8 +132,8 @@ export interface GlassfyPlugin {

setDeviceToken(options: { token: string }): Promise<void>;

setExtraUserProperty(options: { extraProperty: [string: any] }): Promise<void>;
setExtraUserProperty(options: { extra: { [key: string]: any } }): Promise<void>;

getUserProperty(): Promise<void>;
getUserProperty(): Promise<{ extra: { [key: string]: any } }>;

}
4 changes: 2 additions & 2 deletions src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
async setExtraUserProperty(options: { extra: { [key: string]: any } }): Promise<void> {
console.log(options);
throw this.unimplemented('Not supported on web.');
}

async getUserProperty(): Promise<void> {
async getUserProperty(): Promise<{ extra: { [key: string]: any } }> {
throw this.unimplemented('Not supported on web.');
}

Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"pretty": true,
"sourceMap": true,
"strict": true,
"target": "es2017"
"target": "es2017",
"forceConsistentCasingInFileNames": true,
"importHelpers": true
},
"files": ["src/index.ts"]
}

0 comments on commit 375e142

Please sign in to comment.