所以我有以下代码:
options = {
url: "http://mywebsite.com/login/" + authService,
pattern: "http://*mywebsite.com/complete/" + authService + "*",
};
forge.tabs.openWithOptions(options, function(data) {
// We've logged in. Do something now
}, function(data) {
forge.logging.error("Error");
});
该代码在 iPhone 模拟器上运行良好,但在 Android 模拟器中不会调用成功回调。它似乎没有注册从 Oauth 转到重定向 url。在模拟器中,它确实加载了我的重定向 URL,但它没有记录它。这是在 forge run 中记录的内容:
[ INFO] I/Forge ( 393): Loading initial page in webview.
[ INFO] I/Forge ( 393): Application in focus, resuming webview.
[ INFO] D/Forge ( 393): Returning event: {"event":"internal.connectionStateChange","params":{"wifi":false,"connected":true}}
[ INFO] D/Forge ( 393): Native call "tabbar.hide" with task.params: {}
[ INFO] D/Forge ( 393): Returning: {"status":"success","callid":"2C1DB06C-9438-4AFD-841B-C2E3BBF8AA85"}
[ INFO] D/Forge ( 393): Native call "tabbar.addButton" with task.params: {"text":"Events","icon":"img/logo-forge.png"}
[ INFO] D/Forge ( 393): Native call "tabbar.addButton" with task.params: {"text":"Activity","icon":"img/logo-forge.png"}
[ INFO] D/Forge ( 393): Native call "tabbar.addButton" with task.params: {"text":"Me","icon":"img/logo-forge.png"}
[ INFO] D/Forge ( 393): Returning: {"content":"37F88F37-9A08-4541-8B1D-D7D08C2605D8","status":"success","callid":"37F88F37-9A08-4541-8B1D-D7D08C2605D8"}
[ INFO] D/Forge ( 393): Returning: {"content":"FFA69B04-006E-45CB-8BD7-A3CBB7E8403C","status":"success","callid":"FFA69B04-006E-45CB-8BD7-A3CBB7E8403C"}
[ INFO] D/Forge ( 393): Returning: {"content":"99681BEB-E79B-4309-B230-90B731A3DA61","status":"success","callid":"99681BEB-E79B-4309-B230-90B731A3DA61"}
[ INFO] D/Forge ( 393): Native call "internal.hideLaunchImage" with task.params: {}
[ INFO] D/Forge ( 393): Native call "tabbar.setActive" with task.params: {"id":"37F88F37-9A08-4541-8B1D-D7D08C2605D8"}
[ INFO] D/Forge ( 393): Returning: {"status":"success","callid":"23F0D9E1-5F63-4F6A-BFE0-14D674CDEB65"}
[ INFO] D/Forge ( 393): Native call "tabs.open" with task.params: {"url":"http://mywebsite.com/login/twitter","pattern":"^http://*mywebsite.com/complete/twitter.*$","title":"Sign in with Twitter"}
[ INFO] I/Forge ( 393): Displaying modal view.
[ INFO] I/Forge ( 393): subView load http://mywebsite.com/login/twitter/
[ INFO] I/Forge ( 393): subView load http://api.twitter.com/oauth/authenticate?oauth_token=TOKEN&oauth_callback=http%3A%2F%2Fmywebsite.com%2Fcomplete%2Ftwitter%2F
如果我无法始终检测到这些 URL 更改,是否可以在某个时间点获取当前选项卡的 URL?
注意:我在后端使用 django-social-auth。