p***@qq.com
p***@qq.com
  • 发布:2024-06-05 11:17
  • 更新:2024-06-05 11:17
  • 阅读:95

【报Bug】plus.runtime.arguments获取不到参数

分类:HTML5+

产品分类: HTML5+

HBuilderX版本号: 4.15

手机系统: Android

手机系统版本号: Android 13

手机厂商: OPPO

手机机型: OPPO Reno5 Pro 5G

打包方式: 云端

示例代码:
   plus.navigator.createShortcut({  
          name: this.appItem.appName,  
          icon: uni.getStorageSync(JSON.stringify(this.appItem.logoUrl)),  
          toast: '',  
          extra: {  appId: this.appItem.appId },  
          // extra: { appItem: JSON.stringify(this.appItem), path: '/1234' },  
          force: false,  
        }, function (e) {  
        uni.showToast({  
          title:'创建成功',  
          icon:'none'  
        });  
      });
  onShow: function () {  
    console.error(plus.runtime.launcher,'plus.runtime.launcher;')  
    // #ifdef APP-PLUS  
    setTimeout(() => {  
      let args = plus.runtime.arguments;  
      console.warn(args,'app-onShow' )  
      if (args) {  
        if (uni.getStorageSync('LoginInfo')) {  
          let appId;  
          if (plus.os.name === 'iOS') {  
            appId = args.split('?appId=')[1];  
          } else {  
            appId = JSON.parse(args).appId;  
          }  
          appTool.getIdTokenAction().then(() => {  
            getThirdLink({ appId }).then((res) => {  
              let appItem = uni.getStorageSync('appItem');  
              const pages = getCurrentPages();  
              const currentPage = pages[pages.length - 1];  
              const currentRoute = currentPage.route;  
              if ((appItem.appId == res.appId && currentRoute == 'pages/webView/superWebview') || currentRoute == 'pages/preView/preView') {  
                if (currentRoute == 'pages/preView/preView') {  
                } else {  
                  plus.runtime.arguments = null;  
                  plus.runtime.arguments = '';  
                }  
                return;  
              }  
              appRouter.appJumpAction(res, 'mainView', 'app', this);  
              plus.runtime.arguments = null;  
              plus.runtime.arguments = '';  
            });  
          });  
        }  
      }  
    }, 100);  
    // #endif  
}  

操作步骤:

通过plus.navigator.hasShortcut创建的应用快捷方式,我创建了两个快捷方式,我首先打开第一个快捷方式能通过 plus.runtime.arguments获取到参数,然后我在把当前快捷方式运行在后台后,在打开第二个快捷方式,再通过 plus.runtime.arguments获取到的参数,还是第一个快捷方式的参数

预期结果:

希望给出解决方案

实际结果:

使用plus.runtime.arguments获取不到参数

bug描述:

安卓端,通过plus.navigator.hasShortcut创建的应用快捷方式,我创建了两个快捷方式,我首先打开第一个快捷方式能通过 plus.runtime.arguments获取到参数,然后我在把当前快捷方式运行在后台后,在打开第二个快捷方式,再通过 plus.runtime.arguments获取到的参数,还是第一个快捷方式的参数。 如果第一次打开的宿体应用,在依次打开快捷方式应用,获取参数正常

2024-06-05 11:17 负责人:无 分享
已邀请:

要回复问题请先登录注册