我正在尝试在ionic中打开Spotify身份验证URL。我正在使用应用程序内浏览器将用户重定向到该位置,然后返回。 (Iab
是InappBrowser,this.url
是有效的网址FYI)。这是我当前的代码:
const browser = this.Iab.create(this.url,"_blank",'location=yes')
browser.on('loadstop').subscribe(function(){
browser.executeScript({code:'alert("hello world")'}).then((cookie) =>{
console.log(cookie)
})
})
我收到错误:我的应用上出现“ ERROR TypeError:无法读取未定义的属性'subscribe'”。而且警报未显示。
不会从iab中显示警报(对于IAB的最新版本,此提示至少在iOS上显示)。因此,请使用console.log满足您的调试需求。以下是有效的方法:
this.browser = this.iab.create(url,"_blank","hidden=yes,toolbar=no");
this.browser.on('loadstop').subscribe(event => {
console.log("load stop", event)
this.browser.show();
this.browser.executeScript({
code: ` //alert will not work here
console.log("HELLO");
`
})
})
希望这会有所帮助。