Preset the data-bridge-platform and data-bridge-components on the body element from the user-agent. This prevents css flashes before the native bridge is registered in the app.
This commit is contained in:
@@ -43,6 +43,17 @@ class ApplicationPlatform < PlatformAgent
|
||||
operating_system == "Windows"
|
||||
end
|
||||
|
||||
def bridge_name
|
||||
case
|
||||
when native? && android? then :android
|
||||
when native? && ios? then :ios
|
||||
end
|
||||
end
|
||||
|
||||
def bridge_components
|
||||
extract_list_from_native_user_agent("bridge-components")
|
||||
end
|
||||
|
||||
def type
|
||||
if native? && android?
|
||||
"native android"
|
||||
@@ -67,4 +78,13 @@ class ApplicationPlatform < PlatformAgent
|
||||
os =~ /Linux/ ? "Linux" : os
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def extract_list_from_native_user_agent(prefix)
|
||||
if native?
|
||||
user_agent.to_s.match(/#{prefix}: \[(.+)\]/) { |matches| matches[1] }.to_s
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user