收藏
回答

鸿蒙分享图片无法唤起微信

https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Share_and_Favorites/ohos.htmlhttps://developers.weixin.qq.com/doc/oplatform/Mobile_App/Access_Guide/ohos.html

问题描述:

工程机版本:mate60, 5.0.0.102

DevEco Studio版本:DevEco Studio 5.0.3.906

SDK版本:OpenHarmony 5.0.0.71

三方库版本:微信版本1.0.0.44; 微信sdk: wechat_ohos_opensdk1.0.0.har

操作步骤:

1、应用内生成图片,图片大小 小于100k

2 、调用微信sdk分享api, 无法唤起微信 (WXManager.wxApi.sendReq(getContext(this) as common.UIAbilityContext, req))

3.控制台无明显错误日志输出

4.但是在微信版本1.0.0.42; 微信sdk: wechat_ohos_opensdk1.0.0.har, 可以正常唤起


/**
 * 分享组件截图到微信
 * @param id: 组件id
 * */
shareBase64ImageToFriend(id: string, shareCallback?: () => void) {
  getComponentSnapshotArrayBuffer(id, (arrayBuffer: ArrayBuffer) => {
    let imageObject = new wxOpenSdk.WXImageObject
    let buf: buffer.Buffer = buffer.from(arrayBuffer);
    imageObject.imageData = buf.toString('base64', 0, buf.length);
    this.shareImageToWxFriend(imageObject, "", shareCallback)
  })
}

private shareImageToWxFriend(imageObject: wxOpenSdk.WXImageObject, title: string, shareCallback?: () => void) {
  let mediaMessage = new wxOpenSdk.WXMediaMessage()
  mediaMessage.mediaObject = imageObject
  if (title) {
    mediaMessage.title = title
  }
  let req = new wxOpenSdk.SendMessageToWXReq()
  req.scene = wxOpenSdk.SendMessageToWXReq.WXSceneSession
  req.message = mediaMessage
  WXManager.wxApi.sendReq(getContext(this) as common.UIAbilityContext, req)
  if (shareCallback) {
    shareCallback()
  }
}


控制台没有看到sdk报错, 没有明显错误日志,如果

{\rtf1\ansi\ansicpg936\cocoartf2761
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0


\f0\fs24 \cf0 18:22:44.998       I     [][OnPointerEvent:188] ac: down: 180513\
18:22:44.998     I     [P:D:180513][OnPointerEvent:199] Last eventId:180463, current eventId:180513\
18:22:44.999     I     [P:D:180513][OnPointerEvent:491] id:180513 recv\
18:22:44.999     I     [input_transfer_station.cpp] OnInputEvent<82>: eid:86,InputId:180513,wid:320,action:2\
18:22:44.999     E     <1805>GetDecorHeight: Get app window decor height failed\
18:22:45.000     I     [window_session_impl.cpp] NotifyPointerEvent<3024>: Input id:180513\
18:22:45.000     I     [(-2:100000:singleton)] pointdown windowId: 320\
18:22:45.000     I     [(100000:100000:scope)] InputTracking id:180513, fingerId:0, type=0, inject=0, isPrivacyMode=0\
18:22:45.001     I     [(100000:100000:scope)] InputTracking id:180513, touch test hitted node info: fingerId: 0\{ tag: Column, frameRect: RectT (0.00, 38.28) - [405.33 x 149.98], depth: 8 \};\
18:22:45.001     I     [(100000:100000:scope)] InputTracking id:180513, touch test hitted recognizer type info: recognizer type ClickRecognizer node info: \{ tag: Column \};\
18:22:45.001     I     [(100000:100000:scope)] Id:180513, click 0 down, ETF: 0, CTP: 0, state: 0\
18:22:45.001     I     [(100000:100000:scope)] Consumed new event id=180513 in ace_container, lastEventInfo: id:180511\
18:22:45.001     I     [window_scene_session_impl.cpp] ConsumePointerEventInner<736>: InputId:180513,wid:320,pointId:0,sourceType:2,winRect:[0,0,1216,2688],needNotifyEvent:1\
18:22:45.002     I     BinderInvoker 92: created invoker 1307313152\
18:22:45.010     I     [][OnPointerEvent:188] ac: move: 180514\
18:22:45.011     I     [B:UK:180514][SetLastProcessedEventId:54] Last eventId:180466, current eventId:180514\
18:22:45.011     I     [][MarkProcessed:71] Ffrt PE: 180468 180514\
18:22:45.099     I     [][OnPointerEvent:188] ac: move, first: 180515-(2024-10-29 18:22:45.010ms), 180524, count: 10, last: ac: up: 180525\
18:22:45.099     I     [P:U:180525][OnPointerEvent:491] id:180525 recv\
18:22:45.099     I     [input_transfer_station.cpp] OnInputEvent<82>: eid:87,InputId:180525,wid:320,action:4\
18:22:45.100     I     [window_session_impl.cpp] NotifyPointerEvent<3024>: Input id:180525\
18:22:45.101     I     [(100000:100000:scope)] InputTracking id:180525, fingerId:0, type=1, inject=0, isPrivacyMode=0\
18:22:45.101     I     [(100000:100000:scope)] Id:180525, click 0 up, state: 0\
18:22:45.101     I     [(100000:100000:scope)] Click try accept\
18:22:45.101     I     [(100000:100000:scope)] Click accepted, tag: Column\
18:22:45.103     I     [(100000:100000:scope)] Get ComponentSnapshot key=share_poster_wrapper_view_id options=\{1.000000, false\} Id=3381 Tag=Column imageCount=4 checkImage=1 RsNodeId=51509542783197\
18:22:45.104     I     [(100000:100000:scope)] Consumed new event id=180525 in ace_container, lastEventInfo: id:180524\
18:22:45.104     I     [window_scene_session_impl.cpp] ConsumePointerEventInner<736>: InputId:180525,wid:320,pointId:0,sourceType:2,winRect:[0,0,1216,2688],needNotifyEvent:1\
18:22:45.106     I     [(100000:100000:scope)] ProcessModalPageScene\
18:22:45.106     I     [(100000:100000:scope)] PageChange CloseKeyboard FrameNode notNeedSoftKeyboard.\
18:22:45.107     I     [(100000:100000:scope)] PageChange CloseKeyboard SoftKeyboard Closes Successfully.\
18:22:45.112     I     Lottie canvas size:65.99999775606047,161.99999499428876\
18:22:45.115     I     --lottie_animator AnimationItem: pull_loading is Loaded\
18:22:45.115     I     --lottie_animator AnimationItem: pull_loading is play\
18:22:45.115     I     [(100000:100000:scope)] animator binds to context 100000, id:340\
18:22:45.115     I     [<private>(<private>)] ohos.animator setExpectedFrameRateRange, id:340\
18:22:45.115     I     --lottie_animator create\
18:22:45.115     I     [<private>(<private>)] ohos.animator play, id:340, AnimatorOption:[20000,0,-1,0.000000,1.000000,linear,forwards,normal]\
18:22:45.115     I     --lottie_animator play\
18:22:45.126     E     creat PixelMap.\
18:22:45.126     I     [(-1:100000:singleton)] ComponentSnapshot successful! pixelMap.width=694 pixelMap.height=1220\
18:22:45.150     I     DoEncode:(694, 1220) cost 14752 us\
18:22:45.185     I     DoEncode:(694, 1220) cost 21131 us\
18:22:45.209     I     DoEncode:(694, 1220) cost 14648 us\
18:22:45.227     I     DoEncode:(694, 1220) cost 9748 us\
18:22:45.245     I     DoEncode:(694, 1220) cost 9032 us\
18:22:45.263     I     DoEncode:(694, 1220) cost 9143 us\
18:22:45.286     I     DoEncode:(694, 1220) cost 11546 us\
18:22:45.305     I     DoEncode:(694, 1220) cost 8043 us\
18:22:45.324     I     DoEncode:(694, 1220) cost 9808 us\
18:22:45.342     I     DoEncode:(694, 1220) cost 8134 us\
18:22:45.366     I     DoEncode:(694, 1220) cost 12538 us\
18:22:45.382     I     DoEncode:(694, 1220) cost 7728 us\
18:22:45.401     I     DoEncode:(694, 1220) cost 8897 us\
18:22:45.406     I     BinderInvoker 92: created invoker 2164458880\
18:22:45.406     I     SendRequest 137: handle:12 desc:*.AbilityManager refcnt:4 644491008\
18:22:45.408     I     --lottie_animator lottie.destroy undefined\
18:22:45.408     I     --lottie_animator AnimationItem: pull_loading  destroy\
18:22:45.408     I     --lottie_animator finish\
18:22:45.408     I     [<private>(<private>)] ohos.animator finish, id:340\
18:22:45.408     I     [(100000:100000:scope)] animator stop, id:340\
18:22:45.408     I     --lottie_animator finish\
18:22:45.408     I     [<private>(<private>)] ohos.animator finish, id:340\
18:22:45.447     I     [(100000:100000:scope)] [@194][ID: 1] The modal UIExtension is created.\
18:22:45.447     I     [(100000:100000:scope)] [@531][ID: 1] OnAttachToFrameNode\
18:22:45.447     I     [(100000:100000:scope)] [@312][ID: 1] The current state is 'NONE' when UpdateWant.\
18:22:45.447     I     [(100000:100000:scope)] [@331][ID: 1] The ability KeyAsync 0, uIExtensionUsage: 0.\
18:22:45.448     I     [(100000:100000:scope)] [@249][ID: 0] The session is created with want = <private>\
18:22:45.448     I     [session.cpp] Session<98>: focusedOnShow:1\
18:22:45.448     I     <2568>GeneratePersistentId: GeneratePersistentId, persistentId: 0, persistentId_: 1122865157\
18:22:45.448     W     AttachObject 179: attach -2128827392 desc:*.ISession assign\
18:22:45.448     I     <82>operator(): persistentId: 1122865157, bundleName: com.huawei.hmsapp.appgallery, moduleName: , abilityName: HwOpenAbility\
18:22:45.448     I     [(100000:100000:scope)] [@479][ID: 1] The state is changing from 'NONE' to 'FOREGROUND'.\
18:22:45.448     I     [(100000:100000:scope)] [@445][ID: 0] NotifyForeground, persistentid = 1122865157.\
18:22:45.449     I     <101>operator(): Activate session with persistentId: 1122865157\
18:22:45.449     I     [ability_manager_client.cpp:343]name: HwOpenAbility com.huawei.hmsapp.appgallery, persistentId: 1122865157, userId: -1.\
18:22:45.449     I     [(100000:100000:scope)] modalNode->GetParent() 0 mark IsProhibitedAddChildNode when sessionId -1122865157,prohibitedRemoveByRouter: 1.\
18:22:45.449     I     [(100000:100000:scope)] Focus view: ModalPage/3428 show\
18:22:45.449     I     [(100000:100000:scope)] Focus view: ModalPage/3379 lost focus\
18:22:45.449     I     [(100000:100000:scope)] Node(ModalPage/3379) on blur by 3\
18:22:45.449     I     [(100000:100000:scope)] Node(Stack/3377) on blur by 3\
18:22:45.449     I     [(100000:100000:scope)] [entry][100000]: create modal page, sessionId=1122865157, isProhibitBack=0, isAsyncModalBinding=0, isAllowedBeCovered=0, prohibitedRemoveByRouter=1\
18:22:45.452       I     SendRequest 137: handle:12 desc:*.AbilityManager refcnt:4 644491008\
18:22:45.456       I     [(100000:100000:scope)] [@610][ID: 0] Display area with 'RectT (0.00, 0.00) - [1216.00 x 2688.00]' notified to uiextension, persistentid = 1122865157.\
18:22:45.457       I     [(100000:100000:scope)] Request focus on focus view: ModalPage/3428.\
18:22:45.457       I     [(100000:100000:scope)] Focus view has no default focus.\
18:22:45.457       I     [(100000:100000:scope)] Node(ModalPage/3428) on focus\
18:22:45.457       I     [(100000:100000:scope)] FocusSwitching end, startReason: 2, endReason: 2, updateReason: 2\
18:22:45.457       I     [(100000:100000:scope)] current focus node info : (ModalPage/3428).\
18:22:45.457       I     [(100000:100000:scope)] FrameNode(ModalPage/3428) notNeedSoftKeyboard.\
18:22:45.457       I     [(100000:100000:scope)] PageChange CloseKeyboard FrameNode notNeedSoftKeyboard.\
18:22:45.457       I     [(100000:100000:scope)] PageChange CloseKeyboard SoftKeyboard Closes Successfully.\
18:22:45.457       I     [(100000:100000:scope)] Request focus on view root scope: ModalPage/3428 return: 1.\
18:22:45.675       I     RSUIDirector::ProcessMessages messageId:89, cmdCount:1, instanceId:100000\
18:22:45.675       I     RSUIDirector::PostTask messageId:89, cmdCount:1, instanceId:100000\
18:22:45.675       I     [(100000:100000:scope)] Focus view: ModalPage/3379 close\
18:22:45.675       I     [(100000:100000:scope)] Focus view: ModalPage/3379 lost focus\
18:22:45.676       I     [EnhanceClientSerialize]Client sessionInfo sent: pid=11993, sessionId=1046884735, seqNum=******058.\
18:22:45.680       I     [EnhanceClientDeserialize]Client sessionInfo updated: pid=11993, sessionId=1046884735, seqNum=******058.\
18:22:45.681       I     [(100000:100000:scope)] security component has not registered, regStatus 0.\
}
回答关注问题邀请回答
收藏

3 个回答

  • 社区技术运营专员-Jahozheng
    社区技术运营专员-Jahozheng
    11-08

    有没有sdk的这行日志,提供一下

    11-08
    有用
    回复 1
    • 陈健
      陈健
      11-13
      所有日志都在上面了, 没有看到对应日志的打印
      11-13
      回复
  • hatake
    hatake
    11-07

    图片需要压缩下,官方文档上说大于32k会有问题

    11-07
    有用
    回复 2
    • 爱吃棒棒冰
      爱吃棒棒冰
      11-12
      这是说的是不能大于 100KB
      11-12
      回复
    • 陈健
      陈健
      11-13
      这说的是缩略图啊
      11-13
      回复
  • 陈健
    陈健
    10-31

    华为工单回复, 需要鸿蒙微信, 以及微信sdk适配; 微信大佬们啥时候适配啊

    10-31
    有用
    回复 1
    • hatake
      hatake
      2天前
      改成uri方式分享吧
      2天前
      回复
登录 后发表内容