Skip to content
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

Add support for Safari on iOS #99

Closed
3 tasks done
iorate opened this issue Jun 13, 2021 · 44 comments
Closed
3 tasks done

Add support for Safari on iOS #99

iorate opened this issue Jun 13, 2021 · 44 comments

Comments

@iorate
Copy link
Owner

iorate commented Jun 13, 2021

Update (Sep 25, 2022)

uBlacklist is now available on iOS/iPadOS 15 thanks to @HoneyLuka !
https://apps.apple.com/us/app/ublacklist-for-safari/id1547912640

TODO:

  • image search
  • news search
  • video search

Apple has announced that iOS 15 will support Safari Web Extensions.
https://developer.apple.com/videos/play/wwdc2021/10104/

Thanks to @HoneyLuka, uBlacklist is already available as a Safari Web Extension on macOS.
I'd like to add support for Safari on iOS because I'm an iPhone and iPad user.

@iorate iorate pinned this issue Jun 13, 2021
@HoneyLuka
Copy link
Contributor

Thanks for your contribution. Can't wait to use it. :)

@HoneyLuka
Copy link
Contributor

And if you need to get control of the macOS app for some reason, please let me know and I will transfer it to you any time. 🙏

@iorate
Copy link
Owner Author

iorate commented Jun 14, 2021

@HoneyLuka
Thanks, but for now I don't need control of the macOS app.

I will contact you here when I implement support for Safari on iOS 15.

iorate added a commit that referenced this issue Sep 15, 2021
add initial support for the modern version of SERP for Chrome and Safari

re: #99
iorate added a commit that referenced this issue Sep 15, 2021
@iorate
Copy link
Owner Author

iorate commented Sep 15, 2021

iOS/iPadOS 15 will be released on Sep 20!
https://www.apple.com/ios/ios-15/

I pushed a commit (9299d45) which added initial support for Safari 15 on iOS.
Although it supports only simple results in the "All" search, it seems to work well on iOS simulator:

Google Search on iOS Simulator The options page on iOS Simulator

I will add support for more types of search results later.

@HoneyLuka Could you please publish "uBlacklist for Safari" for iOS/iPadOS after iOS/iPadOS 15 are released and you think this extension supports them sufficiently?

@HoneyLuka
Copy link
Contributor

@iorate Thanks for your work🎉, I think it's fine for a first release on iOS. I am now starting to work on the iOS version release preparation

@iorate
Copy link
Owner Author

iorate commented Sep 16, 2021

@HoneyLuka Thank you. I'm looking forward to it.

@iorate
Copy link
Owner Author

iorate commented Sep 18, 2021

The build system was upgraded for faster builds using esbuild-loader.
To generate a production build for Safari:

# Install dependencies
- yarn install --frozen-lockfile
+ yarn install --immutable

# Build
- yarn build:safari:production
+ yarn build safari production

cc: @HoneyLuka

@HoneyLuka
Copy link
Contributor

@iorate Thank you for the tips. I will use it tomorrow.

iOS version almost done. When I finished, I will tell you here.

@HoneyLuka
Copy link
Contributor

@iorate When I debug on iPad, I found an UI issue.
bug

iorate added a commit that referenced this issue Sep 19, 2021
An alternative to browser.identity.launchWebAuthFlow is implemented.
The redirect URL is 'https://iorate.github.io/ublacklist/callback'.

Because Safari on iOS 15 seems not to support browser.tabs.onUpdate
(and browser.tabs.onRemoved) currently, we cannot detect authentication
completion and read the authorization code automatically.
Users need to copy and paste the authorization code manually.

re #99
iorate added a commit that referenced this issue Sep 19, 2021
@iorate
Copy link
Owner Author

iorate commented Sep 19, 2021

@HoneyLuka Thank you for reporting an issue. Does the latest commit (017bf78) fix the problem?

ipad-popup

@HoneyLuka
Copy link
Contributor

@iorate I merged your master branch, It's OK👍

@iorate
Copy link
Owner Author

iorate commented Sep 19, 2021

@HoneyLuka I'm glad to hear that.

I would appreciate if you could also check the sync feature that I added a bit before (3fb1257). Because Safari on iOS lacks some APIs, users need to copy authorization codes from iorate.github.io manually.

@HoneyLuka
Copy link
Contributor

@iorate ok, I will try it later, if any questions I will report to you.

@HoneyLuka
Copy link
Contributor

@iorate I create a test dropbox app, set it's callback url to iorate.github.io.

Most functions are working. Only a little problem:

After sync finished, Appearance, Subscription module do not refresh automatically. Rules textarea show a tips 'updated Reload'. Maybe reload the whole options page automatically after sync?

@iorate
Copy link
Owner Author

iorate commented Sep 19, 2021

@HoneyLuka Thank you for your feedback.

Maybe reload the whole options page automatically after sync?

I don't like automatic reload so much, so added a manual-reload button.
(The screenshot below is taken in Firefox on Windows)

reload

@HoneyLuka
Copy link
Contributor

@iorate I have completed the development of the iOS version, and ready for app store review, the first version is reviewing for external test(TestFlight External Test).

screenshot

If you want to build yourself, you can get code from my branch.

Should I submit the current release to app store or waiting for your next tag and rebuild a new release ?

@iorate
Copy link
Owner Author

iorate commented Sep 20, 2021

@HoneyLuka Great!

Would you please bulid the current master (just marked as v6.4.0) and submit it as v6.4.0?

(As a side note, v6.4.0 will not be released for Chrome & Firefox. v6.3.6 is still under review by Chrome Web Store...)

@HoneyLuka
Copy link
Contributor

@iorate ok, I will rebuild as 6.4.0 later.

@iorate
Copy link
Owner Author

iorate commented Sep 20, 2021

I added v6.4.1 (and perhaps will add more) because v6.3.6 is rejected by Chrome Web Store.
This does not affect the Safari version.

@cyshallchan
Copy link

@HoneyLuka 🤣已经在等了。

@HoneyLuka
Copy link
Contributor

@HoneyLuka 🤣已经在等了。

Welcome to be the first user of iOS version🎉

@HoneyLuka
Copy link
Contributor

HoneyLuka commented Sep 21, 2021

@iorate @cyshallchan iOS version is online🎉 Link

@cyshallchan
Copy link

@iorate @HoneyLuka Already used, thank you two very much.

@iorate
Copy link
Owner Author

iorate commented Sep 21, 2021

@HoneyLuka
I installed "uBlacklist for Safari" to iOS 15 (on iPhone 11 Pro) and iPadOS 15 (on iPad Pro 12.9-inch)
and confirmed it worked well.
Thank you for your excellent work!

@iorate
Copy link
Owner Author

iorate commented Sep 21, 2021

We should add support for:

  • image search
  • news search
  • video search

@iorate
Copy link
Owner Author

iorate commented Sep 22, 2021

Synchronization and subscription updates may not occur regularly. In such cases, the alarms are certainly set, but Safari does not fire them.

alarm

(18 hours behind!)

I'm not sure what the reproduction conditions are.

@HoneyLuka
Copy link
Contributor

@iorate
Does this bug appear when the Safari app is in the background?
Usually in native app of iOS, when the app switches to the background, OS give app a short time to execute code. After that the app will become background/sleep state, can't execute code, and Timer also can't fire(suspend).
When the app active again, the timer will be resume.

I think this bug is very similar to native app. Because Safari is also a native app, when it is in the background, the activity of the extension is suspended due to battery life considerations

@iorate
Copy link
Owner Author

iorate commented Sep 23, 2021

@HoneyLuka
I think it is reasonable that alarms are not fired when Safari is in background, but alarms should be resumed after Safari is back to foreground as you say.

However, I have met some different situations:

  • Sync (every 15 minutes) and subscription (every 2 hours) did not occur after moving Safari from background for several hours to foreground
  • Sync (every 15 minutes) and subscription (every 2 hours) occurred immediately after moving Safari from background for several hours to foreground
  • Sync (every 15 minutes) occurred but subscription (every 2 hours) did not occur after moving Safari from background for several hours to foreground
  • Sync (every 5 minites) and subscription (every 5 minutes) did not occur even when I kept Safari in foreground during the interval

I don't understand the behavior of Safari...

@HoneyLuka
Copy link
Contributor

HoneyLuka commented Sep 23, 2021

@iorate
This may be a bug in Safari, which is not surprising.

If this is indeed a bug, I'm thinking of a solution.
I'm not good at web development. I'm not sure if there is a way to let the extension know about Safari state changes. After a short search, I found an event windows.onFocusChanged. Maybe when Safari become active, this event will be callback. The document said this works after Safari 14 (maybe it's macOS Safari 14).
If it is indeed, in unfocus event remove all alarms, and in focus event recreate them (More complex logic can also be added, for example fire an update immediately or based on last fire time).

Summary Steps:

  1. Check if windows.onFocusChanged is Working properly.
  2. Check recreated alarm is Working properly. (If this bug is more critical, the recreated alarm maybe also does not work properly)
  3. If both is ok, write code on event callback.

@iorate
Copy link
Owner Author

iorate commented Sep 23, 2021

@HoneyLuka
Sounds good.
windows.onFocusChanged seems to work in iOS Simulator.

iorate added a commit that referenced this issue Sep 23, 2021
iorate added a commit that referenced this issue Sep 23, 2021
@iorate
Copy link
Owner Author

iorate commented Sep 24, 2021

I've been trying the windows.onFocusChanged hack for half a day on my iPhone and iPad.
So far, it seems to be working.

@HoneyLuka
Copy link
Contributor

@iorate Glad it works. Thank your for your hard work.

@iorate
Copy link
Owner Author

iorate commented Sep 24, 2021

I believe it works.
@HoneyLuka Would you please publish v6.6.0 when it's convenient for you?

@HoneyLuka
Copy link
Contributor

@iorate Thank you🎉, I will submit it to app store right now.

@HoneyLuka
Copy link
Contributor

iOS 6.6.0 is online now.

@iorate
Copy link
Owner Author

iorate commented Sep 25, 2021

@HoneyLuka
It works well on my actual devices. Thanks!

@love4taylor
Copy link

Is it possible to use CloudKit to synchronize data?

@HoneyLuka
Copy link
Contributor

Is it possible to use CloudKit to synchronize data?

I haven't look this part yet. Usually Apple's services are only available on Apple devices.
Even it is possible, I don't think it's necessary to do this right now.
There is a lot of work to do for this feature.

@iorate
Copy link
Owner Author

iorate commented Oct 3, 2021

Image, news and video search support is available in v6.7.0. cc: @HoneyLuka

@iorate
Copy link
Owner Author

iorate commented Oct 3, 2021

@HoneyLuka The screenshots and captions seem to mismatch in the iPad app.

ipad-screenshot

@HoneyLuka
Copy link
Contributor

@HoneyLuka The screenshots and captions seem to mismatch in the iPad app.

ipad-screenshot

It seems a bug, I will fix it later and release 6.7.0

@HoneyLuka
Copy link
Contributor

iOS 6.7.0 is online🎉

@iorate
Copy link
Owner Author

iorate commented Oct 4, 2021

@HoneyLuka thanks!

@iorate
Copy link
Owner Author

iorate commented Oct 4, 2021

I'm closing this issue because I think basic support for iOS is already done.
For further problems on iOS, please create individual issues for each problem.

@iorate iorate closed this as completed Oct 4, 2021
@iorate iorate unpinned this issue Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants