FIX: only use app argument for official iOS app banner

FIX: only use app argument for official iOS app banner

When showing the native app banner, we include an app argument to automatically add the current site to the official DiscourseHub app. However, the app id can be changed via a hidden site setting, and when changed, that argument is no longer useful. This ensures the argument is only included for the official iOS app banner.

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a440e72..ff7cc87 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -338,6 +338,12 @@ module ApplicationHelper
     current_user && current_user.trust_level >= 1 && SiteSetting.native_app_install_banner_ios
   end
 
+  def ios_app_argument
+    # argument only makes sense for DiscourseHub app
+    SiteSetting.ios_app_id == "1173672076" ?
+      ", app-argument=discourse://new?siteUrl=#{Discourse.base_url}" : ""
+  end
+
   def allow_plugins?
     !request.env[ApplicationController::NO_PLUGINS]
   end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 3f6c9ff..fdebcba 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -44,7 +44,7 @@
     <link rel="manifest" href="<%= Discourse.base_uri %>/manifest.webmanifest" crossorigin="use-credentials">
 
     <%- if include_ios_native_app_banner? %>
-        <meta name="apple-itunes-app" content="app-id=<%= SiteSetting.ios_app_id %>, app-argument=discourse://new?siteUrl=<%= Discourse.base_url %>">
+        <meta name="apple-itunes-app" content="app-id=<%= SiteSetting.ios_app_id %><%= ios_app_argument %>">
     <%- end %>
 
     <%= render partial: "common/discourse_stylesheet" %>

GitHub sha: 0f673507

1 Like