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

Call AuthorizeAndPlayURI on main thread #218

Closed
wants to merge 0 commits into from

Conversation

haashem
Copy link
Contributor

@haashem haashem commented Sep 26, 2024

Fixed a bug caused by my previous PR.

Feel free to change PR title if needed.

Screenshot 2024-09-26 at 20 49 53

@haashem haashem changed the title call aAuthorizeAndPlayURI on main thread which internally calls UIApplication.openURL call AuthorizeAndPlayURI on main thread which internally calls UIApplication.openURL Sep 26, 2024
Comment on lines 18 to 19
s.platform = :ios, '13.0'
s.ios.deployment_target = '13.0'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
s.platform = :ios, '13.0'
s.ios.deployment_target = '13.0'
s.platform = :ios, '12.0'
s.ios.deployment_target = '12.0'

In their readme they say "iOS 12 or higher"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to use Task to call their async authorizeAndPlayURI method in the sync connectToSpotify method, which is only available on iOS 13.

Screenshot 2024-09-26 at 22 32 17

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to maintain compatibility with iOS 12. Isn't there another way to call it on the main thread?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt they are supporting iOS 12, as you see the method is now using async keyword which is only available on iOS 13.

They are using modern syntax which is not available in iOS 12, so there is no way.

Screenshot 2024-09-27 at 18 21 06

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 2 versions of the method. If you use the version with the completion handler you should be able to use it under iOS 12.

Screenshot 2024-09-27 at 21 38 25

Copy link
Contributor Author

@haashem haashem Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, but It's not possible to throw error from non-throwable completion block and I don't know a proper way. most Swift cool features are not supported in iOS 12. the last option is to use completion block for connectToSpotify, which I don't want to try.

Screenshot 2024-09-27 at 22 26 06

Supporting iOS 12 is still needed? considering 6 version behind current iOS 18.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't be throwing at all here. You may replace throw with self.connectionStatusHandler?.connectionResult?(FlutterError(code: "spotifyNotInstalled", message: "Spotify app is not installed", details: nil)).

We match the iOS version support of the native SDK. When the official SDK drops iOS 12 we will drop it as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can work on it tomorrow, Thursday.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fyi: I fixed the linting issues, just rebase on the current main :). @haashem thanks for contributing to this package!

@fotiDim fotiDim changed the title call AuthorizeAndPlayURI on main thread which internally calls UIApplication.openURL Call AuthorizeAndPlayURI on main thread Sep 26, 2024
@haashem haashem closed this Oct 3, 2024
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

Successfully merging this pull request may close these issues.

3 participants