|
| 1 | +/* |
| 2 | + * |
| 3 | + * Copyright 2020 Leanplum Inc. All rights reserved. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License |
| 16 | + **/ |
| 17 | + |
| 18 | +type StatusHandler = (success: boolean) => void; |
| 19 | +type SimpleHandler = () => void; |
| 20 | +type UserAttributes = any; |
| 21 | +export default class Leanplum { |
| 22 | + static _email: string; |
| 23 | + static _deviceName: string; |
| 24 | + static _deviceModel: string; |
| 25 | + static _systemName: string; |
| 26 | + static _systemVersion: string; |
| 27 | + static setApiPath(apiPath: string): void; |
| 28 | + static setEmail(email: string): void; |
| 29 | + /** |
| 30 | + * Sets the network timeout. |
| 31 | + * @param {number} seconds The timeout in seconds. |
| 32 | + */ |
| 33 | + static setNetworkTimeout(seconds: number): void; |
| 34 | + static setVariantDebugInfoEnabled(variantDebugInfoEnabled: boolean): void; |
| 35 | + static getVariantDebugInfo(): {}; |
| 36 | + static setAppIdForDevelopmentMode(appId: string, accessKey: string): void; |
| 37 | + static setAppIdForProductionMode(appId: string, accessKey: string): void; |
| 38 | + static setSocketHost(host: string): void; |
| 39 | + static setDeviceId(deviceId: string): void; |
| 40 | + static setAppVersion(versionName: string): void; |
| 41 | + static setDeviceName(deviceName: string): void; |
| 42 | + static setDeviceModel(deviceModel: string): void; |
| 43 | + static setSystemName(systemName: string): void; |
| 44 | + static setSystemVersion(systemVersion: string): void; |
| 45 | + static setVariables(variables: Object): void; |
| 46 | + static setRequestBatching(batchEnabled: boolean, cooldownSeconds: number): void; |
| 47 | + static getVariables(): any; |
| 48 | + static getVariable(...args: string[]): any; |
| 49 | + static getVariants(): any[]; |
| 50 | + static addStartResponseHandler(handler: StatusHandler): void; |
| 51 | + static addVariablesChangedHandler(handler: SimpleHandler): void; |
| 52 | + static removeStartResponseHandler(handler: StatusHandler): void; |
| 53 | + static removeVariablesChangedHandler(handler: SimpleHandler): void; |
| 54 | + static forceContentUpdate(callback: StatusHandler): void; |
| 55 | + static start(userId: string, callback: StatusHandler): void; |
| 56 | + static start(userAttributes?: UserAttributes, callback?: StatusHandler): void; |
| 57 | + static startFromCache(userId: string, callback: StatusHandler): void; |
| 58 | + static startFromCache(userAttributes?: UserAttributes, callback?: StatusHandler): void; |
| 59 | + static stop(): void; |
| 60 | + static pauseSession(): void; |
| 61 | + static resumeSession(): void; |
| 62 | + static pauseState(): void; |
| 63 | + static resumeState(): void; |
| 64 | + static setUserId(userId: string): void; |
| 65 | + static setUserAttributes(userId: string, userAttributes?: UserAttributes): void; |
| 66 | + static track(event: string, value: number, params: Object): void; |
| 67 | + static track(event: string, params: Object): void; |
| 68 | + static advanceTo(state: string, params?: Object): void; |
| 69 | + /** |
| 70 | + * Determines if web push is supported in the browser. |
| 71 | + * @return {Boolean} True if supported, else false. |
| 72 | + */ |
| 73 | + static isWebPushSupported(): boolean; |
| 74 | + /** |
| 75 | + * Determines if web push is subscribed. |
| 76 | + * @return {Promise} Resolves if true, rejects if false. |
| 77 | + */ |
| 78 | + static isWebPushSubscribed(): Promise<boolean>; |
| 79 | + /** |
| 80 | + * Register the browser for web push. |
| 81 | + * @param {string} serviceWorkerUrl The url on your server that hosts the |
| 82 | + * /sw.min.js service worker js file. |
| 83 | + * @return {Promise} Resolves if registration successful, |
| 84 | + * otherwise fails. |
| 85 | + */ |
| 86 | + static registerForWebPush(serviceWorkerUrl: string): Promise<boolean>; |
| 87 | + /** |
| 88 | + * Unregisters the browser form web push. |
| 89 | + * @return {Promise} Resolves on success, otherwise rejects. |
| 90 | + */ |
| 91 | + static unregisterFromWebPush(): Promise<string>; |
| 92 | + /** |
| 93 | + * Clears cached values for messages, variables and test assignments. |
| 94 | + * Use sparingly as if the app is updated, you'll have to deal with potentially |
| 95 | + * inconsistent state or user experience. |
| 96 | + */ |
| 97 | + static clearUserContent(): void; |
| 98 | +} |
| 99 | +export {}; |
| 100 | + |
0 commit comments