|
|
@@ -3,23 +3,23 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
|
import { window } from '@kit.ArkUI';
|
|
|
import {
|
|
|
AppStorageKeyCollect,
|
|
|
+ IBestInit,
|
|
|
jHStartAd,
|
|
|
permissionController,
|
|
|
+ pushMessageUtil,
|
|
|
YTAvoid,
|
|
|
YTBreakPoint,
|
|
|
YTLog,
|
|
|
- YTUserRequest
|
|
|
+ yTPreferences
|
|
|
} from 'basic';
|
|
|
-import { preferences } from '@kit.ArkData';
|
|
|
import { identifier } from '@kit.AdsKit';
|
|
|
import { BusinessError } from '@kit.BasicServicesKit';
|
|
|
|
|
|
const DOMAIN = 0x0000;
|
|
|
|
|
|
export default class EntryAbility extends UIAbility {
|
|
|
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
|
|
+ async onCreate(_: Want, __: AbilityConstant.LaunchParam) {
|
|
|
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
|
|
|
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
|
|
|
}
|
|
|
|
|
|
onDestroy(): void {
|
|
|
@@ -27,7 +27,6 @@ export default class EntryAbility extends UIAbility {
|
|
|
}
|
|
|
|
|
|
onWindowStageCreate(windowStage: window.WindowStage): void {
|
|
|
-
|
|
|
windowStage.loadContent('/pages/Index'.slice(1), (err) => {
|
|
|
if (err.code) {
|
|
|
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
|
|
@@ -43,10 +42,8 @@ export default class EntryAbility extends UIAbility {
|
|
|
})
|
|
|
|
|
|
PersistentStorage.persistProp<string>(AppStorageKeyCollect.TOKEN, '')
|
|
|
- if (AppStorage.get<string>(AppStorageKeyCollect.TOKEN)) {
|
|
|
- YTUserRequest.refreshUserInfo()
|
|
|
- }
|
|
|
- // IBestInit(windowStage, this.context)
|
|
|
+
|
|
|
+ IBestInit(windowStage, this.context)
|
|
|
bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO)
|
|
|
.then(res => {
|
|
|
YTLog.info(`signatureInfo:` + JSON.stringify(res.signatureInfo))
|
|
|
@@ -56,27 +53,28 @@ export default class EntryAbility extends UIAbility {
|
|
|
})
|
|
|
permissionController.init(this.context)
|
|
|
.then(() => {
|
|
|
- permissionController.askPermissions(["ohos.permission.APP_TRACKING_CONSENT"], (res, err) => {
|
|
|
- if (err) {
|
|
|
- YTLog.error(err)
|
|
|
- } else {
|
|
|
- if (res?.authResults[0] === 0) {
|
|
|
- YTLog.info('succeeded in requesting permission');
|
|
|
- identifier.getOAID((err: BusinessError, data: string) => {
|
|
|
- if (err.code) {
|
|
|
- YTLog.error(`get oaid failed, error: ${err.code} ${err.message}`);
|
|
|
- } else {
|
|
|
- const oaid: string = data;
|
|
|
- jHStartAd.init(this.context, oaid)
|
|
|
- AppStorage.setOrCreate('OAID', oaid)
|
|
|
- YTLog.info(`succeeded in getting oaid by callback , oaid: ${oaid}`);
|
|
|
- }
|
|
|
- });
|
|
|
+ permissionController
|
|
|
+ .askPermissions(["ohos.permission.APP_TRACKING_CONSENT"], (res, err) => {
|
|
|
+ if (err) {
|
|
|
+ YTLog.error(err)
|
|
|
} else {
|
|
|
- YTLog.error('user rejected');
|
|
|
+ if (res?.authResults[0] === 0) {
|
|
|
+ YTLog.info('succeeded in requesting permission');
|
|
|
+ identifier.getOAID((err: BusinessError, data: string) => {
|
|
|
+ if (err.code) {
|
|
|
+ YTLog.error(`get oaid failed, error: ${err.code} ${err.message}`);
|
|
|
+ } else {
|
|
|
+ const oaid: string = data;
|
|
|
+ jHStartAd.init(this.context, oaid)
|
|
|
+ AppStorage.setOrCreate('OAID', oaid)
|
|
|
+ YTLog.info(`succeeded in getting oaid by callback , oaid: ${oaid}`);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ YTLog.error('user rejected');
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
})
|
|
|
// IBestSetGlobalConfig({
|
|
|
// unit: "vp",
|
|
|
@@ -105,13 +103,11 @@ export default class EntryAbility extends UIAbility {
|
|
|
YTBreakPoint.setBreakPoint(windowWidth)
|
|
|
windowClass.on('windowSizeChange', size => {
|
|
|
YTBreakPoint.setBreakPoint(size.width)
|
|
|
+ AppStorage.setOrCreate(AppStorageKeyCollect.SCREEN_WIDTH, px2vp(size.width))
|
|
|
+ AppStorage.setOrCreate(AppStorageKeyCollect.SCREEN_HEIGHT, px2vp(size.height))
|
|
|
})
|
|
|
- //创建首选项 category
|
|
|
- let preference: preferences.Preferences | null = null
|
|
|
- preference = preferences.getPreferencesSync(getContext(), {
|
|
|
- name: 'category'
|
|
|
- })
|
|
|
- AppStorage.setOrCreate<preferences.Preferences>('category', preference)
|
|
|
+ yTPreferences.init(this.context)
|
|
|
+ pushMessageUtil.init(this.context)
|
|
|
});
|
|
|
|
|
|
}
|