mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
FEATURE: Native app banner improvements
This commit adds some improvements to native app banners for iOS and Android - iOS and Android now have separate settings for native app banners - app banners will now only show for users on TL1 and up - app ids are now in a hidden site setting to allow sites to switch to their own app, if desired - iOS only: the site URL is passed to the app arguments
This commit is contained in:
@ -51,13 +51,13 @@ class MetadataController < ApplicationController
|
|||||||
|
|
||||||
manifest[:short_name] = SiteSetting.short_title if SiteSetting.short_title.present?
|
manifest[:short_name] = SiteSetting.short_title if SiteSetting.short_title.present?
|
||||||
|
|
||||||
if SiteSetting.native_app_install_banner
|
if current_user && current_user.trust_level >= 1 && SiteSetting.native_app_install_banner_android
|
||||||
manifest = manifest.merge(
|
manifest = manifest.merge(
|
||||||
prefer_related_applications: true,
|
prefer_related_applications: true,
|
||||||
related_applications: [
|
related_applications: [
|
||||||
{
|
{
|
||||||
platform: "play",
|
platform: "play",
|
||||||
id: "com.discourse"
|
id: SiteSetting.android_app_id
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -325,6 +325,10 @@ module ApplicationHelper
|
|||||||
request.env[ApplicationController::NO_CUSTOM]
|
request.env[ApplicationController::NO_CUSTOM]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def include_ios_native_app_banner?
|
||||||
|
current_user && current_user.trust_level >= 1 && SiteSetting.native_app_install_banner_ios
|
||||||
|
end
|
||||||
|
|
||||||
def allow_plugins?
|
def allow_plugins?
|
||||||
!request.env[ApplicationController::NO_PLUGINS]
|
!request.env[ApplicationController::NO_PLUGINS]
|
||||||
end
|
end
|
||||||
|
@ -46,8 +46,8 @@
|
|||||||
<%= render_google_universal_analytics_code %>
|
<%= render_google_universal_analytics_code %>
|
||||||
<link rel="manifest" href="<%= Discourse.base_uri %>/manifest.webmanifest" crossorigin="use-credentials">
|
<link rel="manifest" href="<%= Discourse.base_uri %>/manifest.webmanifest" crossorigin="use-credentials">
|
||||||
|
|
||||||
<%- if SiteSetting.native_app_install_banner? %>
|
<%- if include_ios_native_app_banner? %>
|
||||||
<meta name="apple-itunes-app" content="app-id=1173672076">
|
<meta name="apple-itunes-app" content="app-id=<%= SiteSetting.ios_app_id %>, app-argument=discourse://new?siteUrl=<%= Discourse.base_url %>">
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
<%= render partial: "common/discourse_stylesheet" %>
|
<%= render partial: "common/discourse_stylesheet" %>
|
||||||
|
@ -1892,7 +1892,9 @@ en:
|
|||||||
|
|
||||||
topic_page_title_includes_category: "Topic page title includes the category name."
|
topic_page_title_includes_category: "Topic page title includes the category name."
|
||||||
|
|
||||||
native_app_install_banner: "Asks recurring visitors to install Discourse native app."
|
native_app_install_banner_ios: "Displays DiscourseHub app banner on iOS devices to regular users (trust level 1 and up)."
|
||||||
|
|
||||||
|
native_app_install_banner_android: "Displays DiscourseHub app banner on Android devices to regular users (trust level 1 and up)."
|
||||||
|
|
||||||
share_anonymized_statistics: "Share anonymized usage statistics."
|
share_anonymized_statistics: "Share anonymized usage statistics."
|
||||||
|
|
||||||
|
@ -1826,7 +1826,17 @@ uncategorized:
|
|||||||
default: true
|
default: true
|
||||||
client: true
|
client: true
|
||||||
|
|
||||||
native_app_install_banner: false
|
native_app_install_banner_ios: false
|
||||||
|
|
||||||
|
native_app_install_banner_android: false
|
||||||
|
|
||||||
|
ios_app_id:
|
||||||
|
default: "1173672076"
|
||||||
|
hidden: true
|
||||||
|
|
||||||
|
android_app_id:
|
||||||
|
default: "com.discourse"
|
||||||
|
hidden: true
|
||||||
|
|
||||||
pwa_display_browser_regex:
|
pwa_display_browser_regex:
|
||||||
default: "iPad|iPhone"
|
default: "iPad|iPhone"
|
||||||
@ -1913,7 +1923,7 @@ user_preferences:
|
|||||||
- normal
|
- normal
|
||||||
- larger
|
- larger
|
||||||
- largest
|
- largest
|
||||||
|
|
||||||
default_title_count_mode:
|
default_title_count_mode:
|
||||||
type: enum
|
type: enum
|
||||||
default: notifications
|
default: notifications
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
class MigrateNativeAppBannerSiteSetting < ActiveRecord::Migration[5.2]
|
||||||
|
def up
|
||||||
|
execute "INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
||||||
|
SELECT 'native_app_install_banner_android', 5, value, now(), now()
|
||||||
|
FROM site_settings
|
||||||
|
WHERE name = 'native_app_install_banner'"
|
||||||
|
|
||||||
|
execute "UPDATE site_settings
|
||||||
|
SET name = 'native_app_install_banner_ios'
|
||||||
|
WHERE name = 'native_app_install_banner'"
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
execute "UPDATE site_settings
|
||||||
|
SET name = 'native_app_install_banner'
|
||||||
|
WHERE name = 'native_app_install_banner_ios'"
|
||||||
|
|
||||||
|
execute "DELETE FROM site_settings WHERE name = 'native_app_install_banner_android'"
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue
Block a user