This commit is contained in:
Ali 2020-03-21 23:11:21 +04:00
parent a52334046d
commit 2fadeebbfa
3 changed files with 65 additions and 77 deletions

View File

@ -624,6 +624,62 @@ ios_extension(
],
)
swift_library(
name = "NotificationServiceExtensionLib",
module_name = "NotificationServiceExtensionLib",
srcs = glob([
"NotificationServiceNext/**/*.swift",
]),
deps = [
],
)
plist_fragment(
name = "NotificationServiceInfoPlist",
extension = "plist",
template =
"""
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.NotificationService</string>
<key>CFBundleName</key>
<string>Telegram</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.usernotifications.service</string>
<key>NSExtensionPrincipalClass</key>
<string>NotificationService</string>
</dict>
""".format(
telegram_bundle_id = telegram_bundle_id,
)
)
ios_extension(
name = "NotificationServiceExtension",
bundle_id = "{telegram_bundle_id}.NotificationService".format(
telegram_bundle_id = telegram_bundle_id,
),
families = [
"iphone",
"ipad",
],
infoplists = [
":NotificationServiceInfoPlist",
":VersionInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "10.0",
provisioning_profile = "//build-input/data/provisioning-profiles:NotificationService.mobileprovision",
deps = [":NotificationServiceExtensionLib"],
frameworks = [
],
)
plist_fragment(
name = "TelegramInfoPlist",
extension = "plist",
@ -813,6 +869,7 @@ ios_application(
],
extensions = [
":ShareExtension",
":NotificationServiceExtension",
],
watch_application = ":TelegramWatchApp",
deps = [

View File

@ -0,0 +1,8 @@
import Foundation
import UserNotifications
@available(iOSApplicationExtension 10.0, *)
@objc(NotificationService)
public final class NotificationService: UNNotificationServiceExtension {
}

View File

@ -1,77 +0,0 @@
load("//build-system:defines.bzl",
"string_value",
)
def _telegram_info_plist(ctx):
output = ctx.outputs.out
plist_string = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleShortVersionString</key>
<string>{app_version}</string>
<key>CFBundleVersion</key>
<string>{build_number}</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>{bundle_id}</string>
<key>CFBundleURLSchemes</key>
<array>
<string>telegram</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>{bundle_id}.ton</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ton</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>{app_name}.compatibility</string>
<key>CFBundleURLSchemes</key>
<array>
<string>{url_scheme}</string>
</array>
</dict>
</array>
</dict>
</plist>
""".format(
app_version = string_value(ctx, ctx.attr.app_version_define),
build_number = string_value(ctx, ctx.attr.build_number_define),
bundle_id = string_value(ctx, ctx.attr.bundle_id_define),
app_name = ctx.attr.app_name,
url_scheme = ctx.attr.url_scheme,
)
ctx.actions.write(
output = output,
content = plist_string,
)
telegram_info_plist = rule(
implementation = _telegram_info_plist,
attrs = {
"app_name": attr.string(mandatory = True),
"url_scheme": attr.string(mandatory = True),
"bundle_id_define": attr.string(mandatory = True),
"app_version_define": attr.string(mandatory = True),
"build_number_define": attr.string(mandatory = True),
},
outputs = {
"out": "%{name}.plist"
},
)