react-native-sdk-pianoio 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +176 -186
  2. package/android/build.gradle +29 -42
  3. package/android/gradle.properties +33 -14
  4. package/android/src/main/java/com/sdkpianoio/ComposerPianoImpl.kt +366 -0
  5. package/android/src/main/java/com/sdkpianoio/SdkPianoioModule.kt +281 -507
  6. package/android/src/main/java/com/sdkpianoio/TokenService.kt +139 -0
  7. package/android/test.sh +494 -0
  8. package/ios/ComposerPianoImpl.swift +128 -225
  9. package/ios/MyComposerDelegate.swift +142 -109
  10. package/ios/SdkPianoio.swift +69 -143
  11. package/ios/SdkPianoioBridge.m +18 -46
  12. package/ios/TokenService.swift +219 -0
  13. package/lib/commonjs/NativeSdkPianoio.ts +34 -10
  14. package/lib/commonjs/PianoComposer.js +69 -51
  15. package/lib/commonjs/PianoComposer.js.map +1 -1
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/module/NativeSdkPianoio.ts +34 -10
  18. package/lib/module/PianoComposer.js +70 -51
  19. package/lib/module/PianoComposer.js.map +1 -1
  20. package/lib/module/index.js +0 -14
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/typescript/commonjs/src/NativeSdkPianoio.d.ts +27 -9
  23. package/lib/typescript/commonjs/src/NativeSdkPianoio.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/src/PianoComposer.d.ts +45 -18
  25. package/lib/typescript/commonjs/src/PianoComposer.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  27. package/lib/typescript/module/src/NativeSdkPianoio.d.ts +27 -9
  28. package/lib/typescript/module/src/NativeSdkPianoio.d.ts.map +1 -1
  29. package/lib/typescript/module/src/PianoComposer.d.ts +45 -18
  30. package/lib/typescript/module/src/PianoComposer.d.ts.map +1 -1
  31. package/lib/typescript/module/src/index.d.ts.map +1 -1
  32. package/package.json +4 -1
  33. package/src/NativeSdkPianoio.ts +34 -10
  34. package/src/PianoComposer.tsx +76 -59
  35. package/src/index.tsx +0 -14
  36. package/android/src/main/AndroidManifestNew.xml +0 -2
  37. package/ios/services/TokenService.swift +0 -70
@@ -1,14 +1,32 @@
1
+ /**
2
+ * This interface defines the full API surface of the native module.
3
+ * It is a complete and accurate representation of the methods exposed
4
+ * in SdkPianoioModule.kt.
5
+ */
1
6
  interface SdkPianoioType {
2
- initializeComposer(aid: string): Promise<boolean>;
7
+ initialize(aid: string): Promise<boolean>;
8
+ addTag(tag: string): Promise<boolean>;
9
+ addTags(tags: string[]): Promise<boolean>;
10
+ setZoneId(zoneId: string): Promise<boolean>;
11
+ setReferrer(referrer: string): Promise<boolean>;
12
+ setUrl(url: string): Promise<boolean>;
13
+ setUserToken(token: string): Promise<boolean>;
14
+ addCustomVariable(key: string, value: string): Promise<boolean>;
15
+ setCustomVariables(variables: {
16
+ [key: string]: string;
17
+ }): Promise<boolean>;
3
18
  executeExperience(): Promise<any>;
4
- getComposer(): Promise<any>;
5
- addComposerTag(tag: string): Promise<void>;
6
- addComposerTags(tags: string[]): Promise<void>;
7
- setComposerZoneId(zoneId: string): Promise<void>;
8
- setComposerReferrer(referrer: string): Promise<void>;
9
- setComposerUrl(url: string): Promise<void>;
10
- setComposerCustomVariable(name: string, value: string): Promise<void>;
11
- setComposerUserToken(token: string): Promise<void>;
19
+ signIn(): Promise<any>;
20
+ signOut(): Promise<any>;
21
+ getCurrentUser(): Promise<any>;
22
+ isAuthenticated(): Promise<any>;
23
+ getStatus(): Promise<any>;
24
+ isInitialized(): Promise<boolean>;
25
+ clearConfiguration(): Promise<boolean>;
26
+ removeTag(tag: string): Promise<boolean>;
27
+ removeCustomVariable(key: string): Promise<boolean>;
28
+ clearTags(): Promise<boolean>;
29
+ clearCustomVariables(): Promise<boolean>;
12
30
  }
13
31
  declare const _default: SdkPianoioType;
14
32
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeSdkPianoio.d.ts","sourceRoot":"","sources":["../../../../src/NativeSdkPianoio.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;IACtB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IAE5B,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;wBAW4B,cAAc;AAA3C,wBAA4C"}
1
+ {"version":3,"file":"NativeSdkPianoio.d.ts","sourceRoot":"","sources":["../../../../src/NativeSdkPianoio.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,UAAU,cAAc;IAEtB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAG1C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,SAAS,CAAC,MAAM,EAAE,MAAM,GA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ented API for interacting with the Piano SDK.
4
+ */
1
5
  declare class PianoComposer {
2
- private aid;
3
- private tags;
4
- private zoneId;
5
- private referrer;
6
- private customVariables;
7
- private userToken;
8
- private url;
9
6
  private constructor();
10
7
  /**
11
8
  * Creates and initializes a new PianoComposer instance.
12
- * This is the entry point for using the library.
9
+ * This is the main entry point for using the library.
13
10
  * @param aid Your Application ID from Piano.io
14
11
  */
15
12
  static create(aid: string): Promise<PianoComposer>;
16
- addTag(tag: string): Promise<void>;
17
- addTags(tags: string[]): Promise<void>;
18
- setZoneId(zoneId: string): Promise<void>;
19
- setReferrer(referrer: string): Promise<void>;
20
- setCustomVariable(name: string, value: string): Promise<void>;
21
- setUserToken(token: string): Promise<void>;
22
- setUrl(url: string): Promise<void>;
13
+ addTag(tag: string): Promise<boolean>;
14
+ addTags(tags: string[]): Promise<boolean>;
15
+ setZoneId(zoneId: string): Promise<boolean>;
16
+ setReferrer(referrer: string): Promise<boolean>;
17
+ setCustomVariable(name: string, value: string): Promise<boolean>;
18
+ setCustomVariables(variables: {
19
+ [key: string]: string;
20
+ }): Promise<boolean>;
21
+ setUserToken(token: string): Promise<boolean>;
22
+ setUrl(url: string): Promise<boolean>;
23
+ /**
24
+ * Signs in the user with Piano.
25
+ * @returns A promise that resolves with user information.
26
+ */
27
+ signIn(): Promise<any>;
28
+ /**
29
+ * Signs out the current user.
30
+ * @returns A promise that resolves when sign out is complete.
31
+ */
32
+ signOut(): Promise<any>;
33
+ /**
34
+ * Gets information about the current authenticated user.
35
+ * @returns A promise that resolves with user information.
36
+ */
37
+ getCurrentUser(): Promise<any>;
38
+ /**
39
+ * Checks if a user is currently authenticated.
40
+ * @returns A promise that resolves with the authentication status.
41
+ */
42
+ isAuthenticated(): Promise<any>;
23
43
  /**
24
44
  * Executes the Piano experience with the current configuration.
25
45
  * This is the primary method to get a decision from the Piano backend.
26
46
  * @returns A promise that resolves with the event data object from the native SDK.
27
47
  */
28
48
  executeExperience(): Promise<any>;
29
- static isInitialized(): Promise<boolean>;
30
- static getComposerFromSdkIOS(): Promise<any>;
31
- toString(): Promise<string>;
49
+ /**
50
+ * Gets the current status of the SDK.
51
+ * @returns A promise that resolves with status information.
52
+ */
53
+ getStatus(): Promise<any>;
54
+ /**
55
+ * Clears all configured tags and custom variables.
56
+ * @returns A promise that resolves when the configuration is cleared.
57
+ */
58
+ clearConfiguration(): Promise<boolean>;
32
59
  }
33
60
  export default PianoComposer;
34
61
  //# sourceMappingURL=PianoComposer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PianoComposer.d.ts","sourceRoot":"","sources":["../../../../src/PianoComposer.tsx"],"names":[],"mappings":"AAEA,cAAM,aAAa;IAEjB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,eAAe,CAAiC;IACxD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,GAAG,CAAuB;IAGlC,OAAO;IAIP;;;;OAIG;WACU,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAOlD,MAAM,CAAC,GAAG,EAAE,MAAM;IAKlB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE;IAKtB,SAAS,CAAC,MAAM,EAAE,MAAM;IAKxB,WAAW,CAAC,QAAQ,EAAE,MAAM;IAK5B,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAK7C,YAAY,CAAC,KAAK,EAAE,MAAM;IAK1B,MAAM,CAAC,GAAG,EAAE,MAAM;IAOxB;;;;OAIG;IACG,iBAAiB;WAOV,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;WASjC,qBAAqB;IAI5B,QAAQ;CAWf;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"PianoComposer.d.ts","sourceRoot":"","sources":["../../../../src/PianoComposer.tsx"],"names":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ourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-sdk-pianoio",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Piano io sdk integration",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -214,5 +214,8 @@
214
214
  "type": "turbo-module",
215
215
  "languages": "kotlin-objc",
216
216
  "version": "0.48.9"
217
+ },
218
+ "dependencies": {
219
+ "@react-native-community/cli-platform-android": "^18.0.0"
217
220
  }
218
221
  }
@@ -1,17 +1,41 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
2
 
3
+ /**
4
+ * This interface defines the full API surface of the native module.
5
+ * It is a complete and accurate representation of the methods exposed
6
+ * in SdkPianoioModule.kt.
7
+ */
3
8
  interface SdkPianoioType {
4
- initializeComposer(aid: string): Promise<boolean>;
9
+ // Initialization
10
+ initialize(aid: string): Promise<boolean>;
11
+
12
+ // Configuration
13
+ addTag(tag: string): Promise<boolean>;
14
+ addTags(tags: string[]): Promise<boolean>;
15
+ setZoneId(zoneId: string): Promise<boolean>;
16
+ setReferrer(referrer: string): Promise<boolean>;
17
+ setUrl(url: string): Promise<boolean>;
18
+ setUserToken(token: string): Promise<boolean>;
19
+ addCustomVariable(key: string, value: string): Promise<boolean>;
20
+ setCustomVariables(variables: { [key: string]: string }): Promise<boolean>;
21
+
22
+ // Execution
5
23
  executeExperience(): Promise<any>;
6
- getComposer(): Promise<any>;
7
-
8
- addComposerTag(tag: string): Promise<void>;
9
- addComposerTags(tags: string[]): Promise<void>;
10
- setComposerZoneId(zoneId: string): Promise<void>;
11
- setComposerReferrer(referrer: string): Promise<void>;
12
- setComposerUrl(url: string): Promise<void>;
13
- setComposerCustomVariable(name: string, value: string): Promise<void>;
14
- setComposerUserToken(token: string): Promise<void>;
24
+
25
+ // Authentication
26
+ signIn(): Promise<any>;
27
+ signOut(): Promise<any>;
28
+ getCurrentUser(): Promise<any>;
29
+ isAuthenticated(): Promise<any>;
30
+
31
+ // Status & Cleanup
32
+ getStatus(): Promise<any>;
33
+ isInitialized(): Promise<boolean>;
34
+ clearConfiguration(): Promise<boolean>;
35
+ removeTag(tag: string): Promise<boolean>;
36
+ removeCustomVariable(key: string): Promise<boolean>;
37
+ clearTags(): Promise<boolean>;
38
+ clearCustomVariables(): Promise<boolean>;
15
39
  }
16
40
 
17
41
  const SdkPianoio = NativeModules.SdkPianoio;
@@ -1,65 +1,92 @@
1
1
  import SdkPianoio from './NativeSdkPianoio';
2
2
 
3
+ /**
4
+ * A wrapper class for the native SdkPianoio module that provides a clean,
5
+ * object-oriented API for interacting with the Piano SDK.
6
+ */
3
7
  class PianoComposer {
4
- // --- Properties to hold configuration state ---
5
- private aid: string;
6
- private tags: string[] = [];
7
- private zoneId: string | null = null;
8
- private referrer: string | null = null;
9
- private customVariables: { [key: string]: string } = {};
10
- private userToken: string | null = null;
11
- private url: string | null = null;
12
-
13
8
  // The constructor is private to force users to use the async `create` method.
14
- private constructor(aid: string) {
15
- this.aid = aid;
9
+ private constructor() {
10
+ // This constructor is intentionally empty.
16
11
  }
17
12
 
18
13
  /**
19
14
  * Creates and initializes a new PianoComposer instance.
20
- * This is the entry point for using the library.
15
+ * This is the main entry point for using the library.
21
16
  * @param aid Your Application ID from Piano.io
22
17
  */
23
18
  static async create(aid: string): Promise<PianoComposer> {
24
- await SdkPianoio.initializeComposer(aid);
25
- return new PianoComposer(aid);
19
+ // Call the corrected native initialize method
20
+ await SdkPianoio.initialize(aid);
21
+ return new PianoComposer();
26
22
  }
27
23
 
28
24
  // --- Configuration Methods ---
29
25
 
30
- async addTag(tag: string) {
31
- this.tags.push(tag); // Store state locally
32
- return SdkPianoio.addComposerTag(tag);
26
+ async addTag(tag: string): Promise<boolean> {
27
+ return SdkPianoio.addTag(tag);
28
+ }
29
+
30
+ async addTags(tags: string[]): Promise<boolean> {
31
+ return SdkPianoio.addTags(tags);
32
+ }
33
+
34
+ async setZoneId(zoneId: string): Promise<boolean> {
35
+ return SdkPianoio.setZoneId(zoneId);
36
+ }
37
+
38
+ async setReferrer(referrer: string): Promise<boolean> {
39
+ return SdkPianoio.setReferrer(referrer);
33
40
  }
34
41
 
35
- async addTags(tags: string[]) {
36
- this.tags.push(...tags); // Store state locally
37
- return SdkPianoio.addComposerTags(tags);
42
+ async setCustomVariable(name: string, value: string): Promise<boolean> {
43
+ return SdkPianoio.addCustomVariable(name, value);
38
44
  }
39
45
 
40
- async setZoneId(zoneId: string) {
41
- this.zoneId = zoneId; // Store state locally
42
- return SdkPianoio.setComposerZoneId(zoneId);
46
+ async setCustomVariables(variables: { [key: string]: string }): Promise<boolean> {
47
+ return SdkPianoio.setCustomVariables(variables);
43
48
  }
44
49
 
45
- async setReferrer(referrer: string) {
46
- this.referrer = referrer; // Store state locally
47
- return SdkPianoio.setComposerReferrer(referrer);
50
+ async setUserToken(token: string): Promise<boolean> {
51
+ return SdkPianoio.setUserToken(token);
52
+ }
53
+
54
+ async setUrl(url: string): Promise<boolean> {
55
+ return SdkPianoio.setUrl(url);
56
+ }
57
+
58
+ // --- Authentication Methods ---
59
+
60
+ /**
61
+ * Signs in the user with Piano.
62
+ * @returns A promise that resolves with user information.
63
+ */
64
+ async signIn(): Promise<any> {
65
+ return SdkPianoio.signIn();
48
66
  }
49
67
 
50
- async setCustomVariable(name: string, value: string) {
51
- this.customVariables[name] = value; // Store state locally
52
- return SdkPianoio.setComposerCustomVariable(name, value);
68
+ /**
69
+ * Signs out the current user.
70
+ * @returns A promise that resolves when sign out is complete.
71
+ */
72
+ async signOut(): Promise<any> {
73
+ return SdkPianoio.signOut();
53
74
  }
54
75
 
55
- async setUserToken(token: string) {
56
- this.userToken = token; // Store state locally
57
- return SdkPianoio.setComposerUserToken(token);
76
+ /**
77
+ * Gets information about the current authenticated user.
78
+ * @returns A promise that resolves with user information.
79
+ */
80
+ async getCurrentUser(): Promise<any> {
81
+ return SdkPianoio.getCurrentUser();
58
82
  }
59
83
 
60
- async setUrl(url: string) {
61
- this.url = url; // Store state locally
62
- return SdkPianoio.setComposerUrl(url);
84
+ /**
85
+ * Checks if a user is currently authenticated.
86
+ * @returns A promise that resolves with the authentication status.
87
+ */
88
+ async isAuthenticated(): Promise<any> {
89
+ return SdkPianoio.isAuthenticated();
63
90
  }
64
91
 
65
92
  // --- Core Execution Method ---
@@ -69,36 +96,26 @@ class PianoComposer {
69
96
  * This is the primary method to get a decision from the Piano backend.
70
97
  * @returns A promise that resolves with the event data object from the native SDK.
71
98
  */
72
- async executeExperience() {
73
- // This now correctly calls the native method AND returns the result.
99
+ async executeExperience(): Promise<any> {
74
100
  return SdkPianoio.executeExperience();
75
101
  }
76
102
 
77
- // --- Static Helper Methods ---
103
+ // --- Utility and Cleanup Methods ---
78
104
 
79
- static async isInitialized(): Promise<boolean> {
80
- try {
81
- const result = await SdkPianoio.getComposer();
82
- return result !== null;
83
- } catch (e) {
84
- return false;
85
- }
86
- }
87
-
88
- static async getComposerFromSdkIOS() {
89
- return SdkPianoio.getComposer();
105
+ /**
106
+ * Gets the current status of the SDK.
107
+ * @returns A promise that resolves with status information.
108
+ */
109
+ async getStatus(): Promise<any> {
110
+ return SdkPianoio.getStatus();
90
111
  }
91
112
 
92
- async toString() {
93
- return `PianoComposer {
94
- aid: ${this.aid},
95
- tags: ${this.tags.join(',')},
96
- zoneId: ${this.zoneId},
97
- referrer: ${this.referrer},
98
- customVariables: ${JSON.stringify(this.customVariables)},
99
- userToken: ${this.userToken},
100
- url: ${this.url}
101
- }`;
113
+ /**
114
+ * Clears all configured tags and custom variables.
115
+ * @returns A promise that resolves when the configuration is cleared.
116
+ */
117
+ async clearConfiguration(): Promise<boolean> {
118
+ return SdkPianoio.clearConfiguration();
102
119
  }
103
120
  }
104
121
 
package/src/index.tsx CHANGED
@@ -1,16 +1,2 @@
1
- // import SdkPianoio from './NativeSdkPianoio';
2
1
  export { default as PianoComposer } from './PianoComposer';
3
2
  export { debugNativeModule } from './debug';
4
-
5
- // export const {
6
- // initializeComposer,
7
- // getComposer,
8
- // addComposerTag,
9
- // addComposerTags,
10
- // setComposerZoneId,
11
- // setComposerReferrer,
12
- // setComposerUrl,
13
- // setComposerCustomVariable,
14
- // setComposerUserToken,
15
- // executeComposer
16
- // } = SdkPianoio;
@@ -1,2 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- </manifest>
@@ -1,70 +0,0 @@
1
- //
2
- // TokenService.swift
3
- // Pods
4
- //
5
- // Created by Alessia Sarak on 24.04.2025.
6
- //
7
-
8
- import PianoOAuth
9
-
10
- public class TokenService: NSObject, PianoIDDelegate {
11
-
12
- @Published private(set) var initialized = false
13
- @Published private(set) var token: PianoIDToken?
14
-
15
- public override init() {
16
- /// Set Piano ID settings
17
- PianoID.shared.endpoint = PianoEndpoint.sandbox
18
- PianoID.shared.aid = ComposerPianoImpl.aid
19
-
20
- super.init()
21
-
22
- PianoID.shared.delegate = self
23
-
24
- token = PianoID.shared.currentToken
25
- request { [weak self] _ in
26
- DispatchQueue.main.async {
27
- self?.initialized = true
28
- }
29
- }
30
- }
31
-
32
- func request(completion: @escaping (PianoIDToken?) -> Void) {
33
- if let t = token {
34
- if t.isExpired {
35
- /// Refresh token if expired
36
- PianoID.shared.refreshToken(t.refreshToken) { token, error in
37
- if let t = token {
38
- self.token = t
39
- completion(t)
40
- return
41
- }
42
- completion(nil)
43
- }
44
- } else {
45
- completion(t)
46
- }
47
- return
48
- }
49
-
50
- completion(nil)
51
- }
52
-
53
- /// Sign In callback
54
- public func signIn(result: PianoIDSignInResult!, withError error: Error!) {
55
- if let r = result {
56
- token = r.token
57
- } else {
58
-
59
- }
60
- }
61
-
62
- /// Sign Out callback
63
- public func signOut(withError error: Error!) {
64
- token = nil
65
- }
66
-
67
- /// Cancel callback
68
- public func cancel() {
69
- }
70
- }