-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CB-14187: (ios) Change the InAppBrowser to allow custom schemes #274
base: master
Are you sure you want to change the base?
Conversation
The proposed changes definitely seem to be consistent with the corresponding functionality for Android from GH-263 (CB-14013). A couple more things that could help:
|
Thanks for your review, @brodybits! I've added a test and some documentation. |
Thanks @wvengen. Unfortunately I had some real trouble getting a test demo to work on iOS. A quick demo project that shows this functionality working the same way on both Android and iOS (as closely as possible) would be really helpful. |
Thanks for testing. Apparently I didn't test it enough, sorry. Still, for me it works on iOS, except that sometimes the alert Result verified is shown twice. That is because, apparently, the loadstop event is being fired for customscheme as well. I don't see how that can be avoided, as in My proposal:
|
I gotta say that I am still not able to get it to work on either Android or iOS in my test project at https://github.com/brodybits/cordova-iab-custom-scheme-test-wip (with 1 test link and 3 button tests). I suspect that I am doing something wrong; it would be best if you can issue a PR to correct me. If I would add the proposed version of this plugin using the following command:
then add iOS platform and then run from Xcode, I would get the following console log message on iOS when I click the test link or any test button:
I get the following console log output if I click the test 3 button:
Test does not work for me on Android either. If another Cordova member with more experience with this plugin can review and test I would be grateful. |
It took me some experimentation to find the cause, but the page you load in the whitelist (local page), it is loaded in the Cordova WebView instead of InAppBrowser. Make it Some small corrections in: wvengen/cordova-iab-custom-scheme-test-wip@5917542 (should work without) and wvengen/cordova-iab-custom-scheme-test-wip@821652d (makes link work). |
Thanks @wvengen I will take another look today. |
tests/tests.js
Outdated
} | ||
}); | ||
ref.addEventListener('customscheme', function (e) { | ||
if (e && e.url === "custom://test") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just discovered today that npm run eslint
has a few failures:
/Users/brodybits/Documents/cordova/cordova-plugin-inappbrowser/tests/tests.js
714:32 error Strings must use singlequote quotes
715:1 error Expected indentation of 16 spaces but found 14 indent
715:15 error 'alert' is not defined no-undef
717:1 error Expected indentation of 16 spaces but found 14 indent
717:15 error 'alert' is not defined no-undef
722:13 error 'alert' is not defined no-undef
✖ 6 problems (6 errors, 0 warnings)
3 errors, 0 warnings potentially fixable with the `--fix` option.
I can think of 2 possible solutions for 'alert' is not defined
:
- use
// eslint-disable-line no-undef
- preferred: use
window.alert
(less ugly, more likely to work on Windows platform)
A nice bonus would be to fix alert
--> window.alert
throughout tests.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I went for the bonus in 93077ef (hoping it will help motivate you to complete the review ;) ). Tested it still works (Android).
I pulled the changes from wvengen/cordova-iab-custom-scheme-test-wip@821652d (master branch) into my master branch, doesn't seem to help on either Android or iOS. Gotta say I am getting ready to give up on this one. I just pushed one more change to https://github.com/brodybits/cordova-iab-custom-scheme-test-wip to use your If you want another expert to take a look I suggest you send a request to: mailto:dev@cordova.apache.org |
@brodybits thanks for checking again. The important change is adding Also, I'll look into the eslint output. |
Thanks @wvengen for the update, fixing the eslint warnings, and fixing the alert calls. I will probably need 1-2 weeks to take another look. Apologies for the extra delays. |
No problem, looking forward to getting this merged, somewhere in the coming weeks if all works out. :) |
Hi @brodybits just a reminder, if you see an opportunity to take another look, please don't forget :) |
93077ef
to
238693b
Compare
And passing :) (context: #307 (comment)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me, merging
@wvengen can you help resolve the conflicts? |
Thanks! I'll be happy to rebase on master once #276 is sorted out. |
#276 is merged, so this can be taken care of now I think. |
I will look at it, thanks. |
238693b
to
0ca4dd7
Compare
Rebased. Tested on Android (7) and iOS (iPhone 8) emulator. |
it looks like this change is only for uiwebview.
Should the change also handle custom url for wkwebview? Thanks |
@wvengen could you possibly rebase your change, resolve the conflicts and see if the code has to be migrated/copied to the UIWebView and WKWebView? Thanks a lot! |
We can take care of (trivial) merge conflicts as this ourselves @timbru31 via the GitHub UI, no need to put the work on the original committer. Just did so. |
I believe it’s not just merge conflict, but adding the code to the WKWebView, too?
…Sent from my iPhone
On 24. Apr 2019, at 4:20 PM, Jan Piotrowski ***@***.***> wrote:
We can take care of (trivial) merge conflicts as this ourselves @timbru31 via the GitHub UI, no need to put the work on the original committer. Just did so.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Any help is appreciated here, as I'm not at all familiar with WKWebView, and I don't have that much time currently to look into that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I've already said, WKWebView is currently missing. - to prevent any accidental merge (since there is already one approval) I'm adding a "request changes".
No worries @wvengen - maybe someone else can finish this PR. Thanks a lot for your contributions!
@@ -439,6 +439,21 @@ - (BOOL)isValidCallbackId:(NSString *)callbackId | |||
return NO; | |||
} | |||
|
|||
- (BOOL)isAllowedScheme:(NSString*)scheme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This need to be added to the WKWebView, too.
Platforms affected
What does this PR do?
Implements CB-14187, which adds support for the
AllowedSchemes
preference andcustomscheme
event for iOS.What testing has been done on this change?
Tested on an iPhone 5SE running iOS 11.4.
Checklist
asthough CB-14013 (CB-14013: (android) Change the InAppBrowser to allow custom schemes for oAuth #263) did not include additional tests,I expect it to be unnecessary here as well, I added a manual test (as it needs editingconfig.xml
).