android - Facebook webview fails when shared -
final edit bug. after filing report addressed.
edit
i trying user id in webview of facebook messenger bot. works fine on mobile, yet fails on desktop (web). should not case.
messenger 2.1 release statement gives following quote:
desktop support extensions sdk: new feature extend functionality across mobile , web, creating consistent experience across devices. now, features user id , sharing used accessible on mobile available on desktop well. provides developers easier way test , debug when implementing webview , chat extensions.
there 2 ways user id messenger extensions: getuserid()
, getcontext()
. docs state getuserid()
not available on desktop, make no mention of getcontext()
.
howevew, there bug report states getcontext()
call not yet available on desktop.
the docs mention no other ways of getting user id. how 1 supposed that?
as kicker, if read original question, see getcontext()
work on desktop (web), if webview opened through link sent directly bot.
original
i working on facebook (messenger) bot using webview. basic of tasks userid.
this hit big problem. having investigated thoroughly, below present cases , results.
case 1: app sends me generic template web_url button (that opens webview) , share button.
everything works great. user id.
case 2: click share message in
case 1
, , share myself , app.from either message thread (i myself, or app)
getcontext()
call return error2018166 permission not valid call sdk api.
,askpermission()
returns2018154 messenger extensions unexpected error.
case 3: click share inside webview using
beginshareflow()
, share myself , bot.same
case 2
case 4: here's kicker.
activating webview
case 2
orcase 3
android, works , gives me user id.case 5: sharing friend has interacted app before.
when friend activates webview, desktop fails, android works.
case 6: sharing friend has not interacted bot.
on desktop doesn't work (sharing button or through
beginshareflow()
), works!
so, after writing of out, pattern is:
- on android, webview sharing works expected: can user id whether have interacted bot befor or not.
- on desktop, time webview provides user id, when message webview link sent bot. once shared user, webview still opens, not provide context.
just clarify. user id using getcontext
, , not getuserid
docs doesn't work on desktop.
is there can this? bot's webviews work both on desktop , mobile.
i can think of workaround, it's far ideal
edit 2
as requested, payload sharing within webview is:
{ "attachment":{ "type":"template", "payload":{ "template_type":"generic", "elements": [{ "title":"testing webview", "default_action":{ "type":"web_url", "webview_height_ratio": "full", "messenger_extensions": true, "url":"https://plenty.life/webview" }, "buttons":[{ "type":"web_url", "webview_height_ratio": "full", "messenger_extensions": true, "url":"https://plenty.life/webview", "title":"test" }] }] } } }
try this...
<script> window.extasyncinit = function() { // messenger extensions js sdk done loading console.log("using getuserid in",window.name) messengerextensions.getuserid(function success(uids) { // user id obtained. var psid = uids.psid; console.log(psid); document.getelementbyid("userid").innertext="your user id "+psid; }, function error(err, errormessage) { // error handling code console.log("some error",err,errormessage) }); messengerextensions.getcontext('<appid>', function success(result){ console.log("success",result) }, function error(result){ console.log("error",result) } ); }; </script>
wiki
Comments
Post a Comment