Ionic:无法追加UserAgent

问题描述 投票:0回答:1

我有一个带有离子+电容器的android/ios应用程序。电容器版本为v5。我想将自定义字符串附加到用户代理,但没有任何效果。

这是我的配置文件:

        /// <reference types="@capacitor/push-notifications" />
/// <reference types="@capacitor/splash-screen" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
    appId: 'io.icoders.jobinfo',
    appName: 'Jobinfo',
    webDir: 'dist',
    plugins: {
        SplashScreen: {
            launchShowDuration: 5000,
            launchAutoHide: true,
            backgroundColor: '#ffffffff',
            androidSplashResourceName: 'splash',
            androidScaleType: 'CENTER_CROP',
            showSpinner: true,
            androidSpinnerStyle: 'large',
            iosSpinnerStyle: 'small',
            spinnerColor: '#999999',
            splashFullScreen: true,
            splashImmersive: false,
            layoutName: 'launch_screen',
            useDialog: false
        }
    },
    appendUserAgent: 'JobinfoApp',
    overrideUserAgent: 'JobinfoApp',
    android: {
        appendUserAgent: 'JobinfoApp',
        overrideUserAgent: 'JobinfoApp',
    },
    ios: {
        appendUserAgent: 'JobinfoApp',
        overrideUserAgent: 'JobinfoApp',
    }
};

export default config;

我已经在ios和android标签中尝试了“appendUserAgent”配置,也在主体中尝试过,不起作用,useragent恢复了原来的状态。有什么问题吗?

ionic-framework user-agent capacitor
1个回答
0
投票

这是一个对我有用的解决方案,但请记住,您只能从模拟器中测试它,在浏览器上使用 Chrome 通过使用“chrome://inspect”来测试它

import { CapacitorConfig } from '@capacitor/cli';

 appendUserAgent: 'appId=app.jobinfo',
© www.soinside.com 2019 - 2024. All rights reserved.