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

Breaking API change: applications can set a User-Agent prefix #56

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

joemasilotti
Copy link
Member

Brings Android PR #77 to iOS, allowing developers to set a custom user agent prefix without breaking bridge components or removing "Hotwire Native".

Developers can set a custom applicationUserAgentPrefix for their application via:

Hotwire.config.applicationUserAgentPrefix = "My Application Prefix;"

Whenever a WKWebView instance is created, the library will now automatically include:

  • Your (optional) custom applicationUserAgentPrefix
  • "Hotwire Native iOS; Turbo Native iOS;"
  • "bridge-components: [your bridge components];"

WKWebView's default user agent will also be added to the beginning of the user agent.

@@ -1,15 +1,29 @@
import Foundation
import HotwireNative
@testable import HotwireNative
Copy link
Member Author

Choose a reason for hiding this comment

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

@testable is needed to access the (now) internal UserAgent function.

Comment on lines 15 to 17
// TODO: Move to AppDelegate when PR #55 is merged.
// https://github.com/hotwired/hotwire-native-ios/pull/55/files
Hotwire.config.applicationUserAgentPrefix = "Hotwire Demo;"
Copy link
Member Author

Choose a reason for hiding this comment

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

Commenting so we don't forget about this to-do.

Copy link
Contributor

Choose a reason for hiding this comment

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

I took care of this here.

Copy link
Contributor

@jayohms jayohms left a comment

Choose a reason for hiding this comment

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

Thanks!

Source/Bridge/UserAgent.swift Outdated Show resolved Hide resolved
Source/Bridge/UserAgent.swift Show resolved Hide resolved
joemasilotti and others added 3 commits December 12, 2024 14:14
* main:
  Set session's path config from the global path config.
  Consolidate all global config by moving it in app delegate.
  Add utility func to load path config to the Hotwire enum.
  Move `matchQueryStrings` to `PathConfiguration`.
  Move `registerBridgeComponents` to `AppDelegate`.
Copy link
Contributor

@svara svara left a comment

Choose a reason for hiding this comment

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

Nicely done @joemasilotti 👏🏻

@svara svara merged commit fe0558d into main Dec 16, 2024
1 check passed
@svara svara deleted the user-agent-prefix branch December 16, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants