src/services/utility-service.ts
Methods |
checkAppAvailability | ||||
checkAppAvailability(packageName)
|
||||
Defined in src/services/utility-service.ts:74
|
||||
Parameters :
Returns :
Promise<string>
|
checkAvailableAppList | ||||||
checkAvailableAppList(packageIds: Array
|
||||||
Defined in src/services/utility-service.ts:240
|
||||||
Parameters :
Returns :
Promise<literal type>
|
clearUtmInfo |
clearUtmInfo()
|
Defined in src/services/utility-service.ts:153
|
Returns :
Promise<any>
|
exportApk | ||||
exportApk(destination)
|
||||
Defined in src/services/utility-service.ts:106
|
||||
Parameters :
Returns :
Promise<string>
|
getApkSize |
getApkSize()
|
Defined in src/services/utility-service.ts:183
|
Returns :
Promise<string>
|
getAppVersionCode |
getAppVersionCode()
|
Defined in src/services/utility-service.ts:217
|
Returns :
Promise<number>
|
getBuildConfigValue | ||||
getBuildConfigValue(property)
|
||||
Defined in src/services/utility-service.ts:10
|
||||
Parameters :
Returns :
Promise<string>
|
getDeviceAPILevel |
getDeviceAPILevel()
|
Defined in src/services/utility-service.ts:58
|
Returns :
Promise<string>
|
getDeviceSpec |
getDeviceSpec()
|
Defined in src/services/utility-service.ts:122
|
Returns :
Promise<DeviceSpecification>
|
getDownloadDirectoryPath |
getDownloadDirectoryPath()
|
Defined in src/services/utility-service.ts:90
|
Returns :
Promise<string>
|
getMetaData | ||||||
getMetaData(filePath: string)
|
||||||
Defined in src/services/utility-service.ts:197
|
||||||
Parameters :
Returns :
Promise<string>
|
getUtmInfo |
getUtmInfo()
|
Defined in src/services/utility-service.ts:138
|
Returns :
Promise<any>
|
openFileManager |
openFileManager()
|
Defined in src/services/utility-service.ts:260
|
Returns :
Promise<any>
|
openPlayStore | ||||
openPlayStore(appId)
|
||||
Defined in src/services/utility-service.ts:42
|
||||
Parameters :
Returns :
Promise<string>
|
readFileFromAssets | ||||||
readFileFromAssets(fileName: string)
|
||||||
Defined in src/services/utility-service.ts:169
|
||||||
Parameters :
Returns :
Promise<string>
|
removeFile | ||||||
removeFile(filePath: string)
|
||||||
Defined in src/services/utility-service.ts:207
|
||||||
Parameters :
Returns :
Promise<boolean>
|
rm | ||||||
rm(directoryPath, directoryToBeSkipped)
|
||||||
Defined in src/services/utility-service.ts:26
|
||||||
Parameters :
Returns :
Promise<string>
|
startActivityForResult | ||||||
startActivityForResult(params: literal type)
|
||||||
Defined in src/services/utility-service.ts:250
|
||||||
Parameters :
Returns :
Promise<string>
|
verifyCaptcha | ||||||
verifyCaptcha(apiKey: string)
|
||||||
Defined in src/services/utility-service.ts:230
|
||||||
Parameters :
Returns :
Promise<string>
|
import {Injectable} from '@angular/core';
import {DeviceSpecification} from 'sunbird-sdk';
import {GenericAppConfig} from '@app/app/app.constant';
declare const sbutility;
@Injectable()
export class UtilityService {
getBuildConfigValue(property): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.getBuildConfigValue('org.sunbird.app', property, (entry: string) => {
resolve(entry);
}, err => {
console.error(err);
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
rm(directoryPath, directoryToBeSkipped): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.rm(directoryPath, directoryToBeSkipped, (entry: string) => {
resolve(entry);
}, err => {
console.error(err);
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
openPlayStore(appId): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.openPlayStore(appId, (entry: string) => {
resolve(entry);
}, err => {
console.error(err);
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
getDeviceAPILevel(): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.getDeviceAPILevel((entry: string) => {
resolve(entry);
}, err => {
console.error(err);
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
checkAppAvailability(packageName): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.checkAppAvailability(packageName, (entry: string) => {
resolve(entry);
}, err => {
console.error(err);
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
getDownloadDirectoryPath(): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.getDownloadDirectoryPath((entry: string) => {
resolve(entry);
}, err => {
console.error(err);
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
exportApk(destination): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.exportApk(destination, (entry: string) => {
resolve(entry);
}, err => {
console.error(err);
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
getDeviceSpec(): Promise<DeviceSpecification> {
return new Promise<DeviceSpecification>((resolve, reject) => {
try {
sbutility.getDeviceSpec((deviceSpec: DeviceSpecification) => {
resolve(deviceSpec);
}, err => {
console.error(err);
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
getUtmInfo(): Promise<any> {
return new Promise<any>((resolve, reject) => {
try {
sbutility.getUtmInfo((utmInfo: any) => {
console.log('utm parameter', utmInfo);
resolve(utmInfo);
}, err => {
reject(err);
});
} catch (xc) {
reject(xc);
}
});
}
clearUtmInfo(): Promise<any> {
return new Promise<any>((resolve, reject) => {
try {
sbutility.clearUtmInfo(() => {
console.log('utm paramter clear');
resolve();
}, err => {
reject(err);
});
} catch (xc) {
console.error(xc);
reject(xc);
}
});
}
readFileFromAssets(fileName: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.readFromAssets(fileName, (entry: string) => {
resolve(entry);
}, err => {
reject(err);
});
} catch (xc) {
reject(xc);
}
});
}
getApkSize(): Promise<string> {
return new Promise<string>((resolve, reject) => {
try {
sbutility.getApkSize((entry: string) => {
resolve(entry);
}, err => {
reject(err);
});
} catch (xc) {
reject(xc);
}
});
}
getMetaData(filePath: string): Promise<string> {
return new Promise((resolve, reject) => {
sbutility.getMetaData([{path: filePath, identifier: 'ecar'}], (data) => {
resolve(data.ecar.size);
}, err => {
reject(err);
});
});
}
removeFile(filePath: string): Promise<boolean> {
return new Promise((resolve, reject) => {
sbutility.rm([filePath], false, (successfullyDeleted) => {
resolve(successfullyDeleted);
}, error => {
reject(error);
});
});
}
getAppVersionCode(): Promise<number> {
return new Promise<number>((resolve, reject) => {
this.getBuildConfigValue(GenericAppConfig.VERSION_CODE)
.then(response => {
resolve(+response);
})
.catch(error => {
console.log('Error--', error);
resolve(0);
});
});
}
verifyCaptcha(apiKey: string): Promise<string> {
return new Promise((resolve, reject) => {
sbutility.verifyCaptcha(apiKey, (data) => {
resolve(data);
}, err => {
reject(err);
});
});
}
checkAvailableAppList(packageIds: Array<string>): Promise<{[packageId: string]: boolean}> {
return new Promise((resolve, reject) => {
sbutility.getAppAvailabilityStatus(packageIds, (data) => {
resolve(data);
}, err => {
reject(err);
});
});
}
startActivityForResult(params: {}): Promise<string> {
return new Promise((resolve, reject) => {
sbutility.startActivityForResult(params, (data) => {
resolve(data);
}, err => {
reject(err);
});
});
}
openFileManager(): Promise<any> {
return new Promise((resolve, reject) => {
sbutility.openFileManager((res) => {
resolve(res);
}, err => {
reject(err);
});
});
}
}