mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
283f481ef2
89
README.md
89
README.md
@ -11,86 +11,85 @@ There are several things we require from **all developers** for the moment.
|
||||
3. Please study our [**security guidelines**](https://core.telegram.org/mtproto/security_guidelines) and take good care of your users' data and privacy.
|
||||
4. Please remember to publish **your** code too in order to comply with the licences.
|
||||
|
||||
# Compilation Guide
|
||||
# Quick Compilation Guide
|
||||
|
||||
1. Install Xcode (directly from https://developer.apple.com/download/more or using the App Store).
|
||||
2. Clone the project from GitHub:
|
||||
## Get the Code
|
||||
|
||||
```
|
||||
git clone --recursive -j8 https://github.com/TelegramMessenger/Telegram-iOS.git
|
||||
```
|
||||
|
||||
3. Adjust configuration parameters
|
||||
## Setup Xcode
|
||||
|
||||
Install Xcode (directly from https://developer.apple.com/download/applications or using the App Store).
|
||||
|
||||
## Adjust Configuration
|
||||
|
||||
1. Generate a random identifier:
|
||||
```
|
||||
openssl rand -hex 8
|
||||
```
|
||||
2. Create a new Xcode project. Use `Telegram` as the Product Name. Use `org.{identifier from step 1}` as the Organization Identifier.
|
||||
3. In Signing & Capabilities click on the `i` next to `Xcode Managed Profile` and copy the team ID (`ABCDEFG123`).
|
||||
4. Edit `build-system/template_minimal_development_configuration.json`. Use data from the previous steps.
|
||||
|
||||
## Generate an Xcode project
|
||||
|
||||
```
|
||||
mkdir -p $HOME/telegram-configuration
|
||||
mkdir -p $HOME/telegram-provisioning
|
||||
cp build-system/appstore-configuration.json $HOME/telegram-configuration/configuration.json
|
||||
cp -R build-system/fake-codesigning $HOME/telegram-provisioning/
|
||||
python3 build-system/Make/Make.py \
|
||||
--cacheDir="$HOME/telegram-bazel-cache" \
|
||||
generateProject \
|
||||
--configurationPath=build-system/template_minimal_development_configuration.json \
|
||||
--xcodeManagedCodesigning
|
||||
```
|
||||
|
||||
- Modify the values in `configuration.json`
|
||||
- Replace the provisioning profiles in `profiles` with valid files
|
||||
# Advanced Compilation Guide
|
||||
|
||||
4. (Optional) Create a build cache directory to speed up rebuilds
|
||||
## Xcode
|
||||
|
||||
1. Copy and edit `build-system/appstore-configuration.json`.
|
||||
2. Copy `build-system/fake-codesigning`. Create and download provisioning profiles, using the `profiles` folder as a reference for the entitlements.
|
||||
3. Generate an Xcode project:
|
||||
```
|
||||
mkdir -p "$HOME/telegram-bazel-cache"
|
||||
python3 build-system/Make/Make.py \
|
||||
--cacheDir="$HOME/telegram-bazel-cache" \
|
||||
generateProject \
|
||||
--configurationPath=configuration_from_step_1.json \
|
||||
--codesigningInformationPath=directory_from_step_2
|
||||
```
|
||||
|
||||
5. Build the app
|
||||
## IPA
|
||||
|
||||
1. Repeat the steps from the previous section. Use distribution provisioning profiles.
|
||||
2. Run:
|
||||
```
|
||||
python3 build-system/Make/Make.py \
|
||||
--cacheDir="$HOME/telegram-bazel-cache" \
|
||||
build \
|
||||
--configurationPath=path-to-configuration.json \
|
||||
--codesigningInformationPath=path-to-provisioning-data \
|
||||
--configurationPath=...see previous section... \
|
||||
--codesigningInformationPath=...see previous section... \
|
||||
--buildNumber=100001 \
|
||||
--configuration=release_universal
|
||||
--configuration=release_arm64
|
||||
```
|
||||
|
||||
6. (Optional) Generate an Xcode project
|
||||
## Tips
|
||||
|
||||
## Codesigning is not required for simulator-only builds
|
||||
|
||||
Add `--disableProvisioningProfiles`:
|
||||
```
|
||||
python3 build-system/Make/Make.py \
|
||||
--cacheDir="$HOME/telegram-bazel-cache" \
|
||||
generateProject \
|
||||
--configurationPath=path-to-configuration.json \
|
||||
--codesigningInformationPath=path-to-provisioning-data \
|
||||
--disableExtensions
|
||||
```
|
||||
|
||||
It is possible to generate a project that does not require any codesigning certificates to be installed: add `--disableProvisioningProfiles` flag:
|
||||
```
|
||||
python3 build-system/Make/Make.py \
|
||||
--cacheDir="$HOME/telegram-bazel-cache" \
|
||||
generateProject \
|
||||
--configurationPath=path-to-configuration.json \
|
||||
--codesigningInformationPath=path-to-provisioning-data \
|
||||
--disableExtensions \
|
||||
--disableProvisioningProfiles
|
||||
```
|
||||
|
||||
## Versions
|
||||
|
||||
Tip: use `--disableExtensions` when developing to speed up development by not building application extensions and the WatchOS app.
|
||||
|
||||
|
||||
# Tips
|
||||
|
||||
Bazel is used to build the app. To simplify the development setup a helper script is provided (`build-system/Make/Make.py`). See help:
|
||||
Each release is built using a specific Xcode version (see `versions.json`). The helper script checks the versions of the installed software and reports an error if they don't match the ones specified in `versions.json`. It is possible to bypass these checks:
|
||||
|
||||
```
|
||||
python3 build-system/Make/Make.py --help
|
||||
python3 build-system/Make/Make.py build --help
|
||||
python3 build-system/Make/Make.py generateProject --help
|
||||
```
|
||||
|
||||
Bazel is automatically downloaded when running Make.py for the first time. If you wish to use your own build of Bazel, pass `--bazel=path-to-bazel`. If your Bazel version differs from that in `versions.json`, you may use `--overrideBazelVersion` to skip the version check.
|
||||
|
||||
Each release is built using specific Xcode and Bazel versions (see `versions.json`). The helper script checks the versions of installed software and reports an error if they don't match the ones specified in `versions.json`. There are flags that allow to bypass these checks:
|
||||
|
||||
```
|
||||
python3 build-system/Make/Make.py --overrideBazelVersion build ... # Don't check the version of Bazel
|
||||
python3 build-system/Make/Make.py --overrideXcodeVersion build ... # Don't check the version of Xcode
|
||||
```
|
||||
|
@ -30,8 +30,11 @@ load(
|
||||
"top_level_target",
|
||||
"top_level_targets",
|
||||
"xcodeproj",
|
||||
"xcode_provisioning_profile",
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_apple//apple:apple.bzl", "local_provisioning_profile")
|
||||
|
||||
load("//build-system/bazel-utils:plist_fragment.bzl",
|
||||
"plist_fragment",
|
||||
)
|
||||
@ -39,6 +42,7 @@ load("//build-system/bazel-utils:plist_fragment.bzl",
|
||||
load(
|
||||
"@build_configuration//:variables.bzl",
|
||||
"telegram_bazel_path",
|
||||
"telegram_use_xcode_managed_codesigning",
|
||||
"telegram_bundle_id",
|
||||
"telegram_aps_environment",
|
||||
"telegram_team_id",
|
||||
@ -510,10 +514,11 @@ app_groups_fragment = """
|
||||
telegram_bundle_id=telegram_bundle_id
|
||||
)
|
||||
|
||||
communication_notifications_fragment = """
|
||||
official_communication_notifications_fragment = """
|
||||
<key>com.apple.developer.usernotifications.communication</key>
|
||||
<true/>
|
||||
"""
|
||||
communication_notifications_fragment = official_communication_notifications_fragment if telegram_bundle_id in official_bundle_ids else ""
|
||||
|
||||
store_signin_fragment = """
|
||||
<key>com.apple.developer.applesignin</key>
|
||||
@ -1920,6 +1925,18 @@ plist_fragment(
|
||||
)
|
||||
)
|
||||
|
||||
local_provisioning_profile(
|
||||
name = "Telegram_local_profile",
|
||||
profile_name = "iOS Team Provisioning Profile: {}".format(telegram_bundle_id),
|
||||
team_id = telegram_team_id,
|
||||
)
|
||||
|
||||
xcode_provisioning_profile(
|
||||
name = "Telegram_xcode_profile",
|
||||
managed_by_xcode = True,
|
||||
provisioning_profile = ":Telegram_local_profile",
|
||||
)
|
||||
|
||||
ios_application(
|
||||
name = "Telegram",
|
||||
bundle_id = "{telegram_bundle_id}".format(
|
||||
@ -1929,7 +1946,7 @@ ios_application(
|
||||
minimum_os_version = minimum_os_version,
|
||||
provisioning_profile = select({
|
||||
":disableProvisioningProfilesSetting": None,
|
||||
"//conditions:default": "@build_configuration//provisioning:Telegram.mobileprovision",
|
||||
"//conditions:default": ":Telegram_xcode_profile" if telegram_use_xcode_managed_codesigning else "@build_configuration//provisioning:Telegram.mobileprovision",
|
||||
}),
|
||||
entitlements = ":TelegramEntitlements.entitlements",
|
||||
infoplists = [
|
||||
|
@ -680,7 +680,7 @@ private final class NotificationServiceHandler {
|
||||
Logger.shared.logToConsole = loggingSettings.logToConsole
|
||||
Logger.shared.redactSensitiveData = loggingSettings.redactSensitiveData
|
||||
|
||||
let networkArguments = NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(buildConfig.bundleData(withAppToken: nil, signatureDict: nil)), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: !buildConfig.isAppStoreBuild)
|
||||
let networkArguments = NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(buildConfig.bundleData(withAppToken: nil, signatureDict: nil)), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: !buildConfig.isAppStoreBuild, isICloudEnabled: false)
|
||||
|
||||
let isLockedMessage: String?
|
||||
if let data = try? Data(contentsOf: URL(fileURLWithPath: appLockStatePath(rootPath: rootPath))), let state = try? JSONDecoder().decode(LockState.self, from: data), isAppLocked(state: state) {
|
||||
|
@ -174,7 +174,7 @@ class DefaultIntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
|
||||
if let accountCache = accountCache {
|
||||
account = .single(accountCache)
|
||||
} else {
|
||||
account = currentAccount(allocateIfNotExists: false, networkArguments: NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(buildConfig.bundleData(withAppToken: nil, signatureDict: nil)), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: !buildConfig.isAppStoreBuild), supplementary: true, manager: accountManager, rootPath: rootPath, auxiliaryMethods: accountAuxiliaryMethods, encryptionParameters: encryptionParameters)
|
||||
account = currentAccount(allocateIfNotExists: false, networkArguments: NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(buildConfig.bundleData(withAppToken: nil, signatureDict: nil)), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: !buildConfig.isAppStoreBuild, isICloudEnabled: false), supplementary: true, manager: accountManager, rootPath: rootPath, auxiliaryMethods: accountAuxiliaryMethods, encryptionParameters: encryptionParameters)
|
||||
|> mapToSignal { account -> Signal<Account?, NoError> in
|
||||
if let account = account {
|
||||
switch account {
|
||||
|
@ -75,3 +75,9 @@ http_archive(
|
||||
sha256 = "032907801dc7784744a1ca8fd40d3eecc34a2e27a93a4b3993f617cca204a9f3",
|
||||
build_file = "@//third-party/AppCenter:AppCenter.BUILD",
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_apple//apple:apple.bzl", "provisioning_profile_repository")
|
||||
|
||||
provisioning_profile_repository(
|
||||
name = "local_provisioning_profiles",
|
||||
)
|
||||
|
@ -35,9 +35,10 @@ class BuildConfiguration:
|
||||
self.enable_siri = enable_siri
|
||||
self.enable_icloud = enable_icloud
|
||||
|
||||
def write_to_variables_file(self, bazel_path, aps_environment, path):
|
||||
def write_to_variables_file(self, bazel_path, use_xcode_managed_codesigning, aps_environment, path):
|
||||
string = ''
|
||||
string += 'telegram_bazel_path = "{}"\n'.format(bazel_path)
|
||||
string += 'telegram_use_xcode_managed_codesigning = {}\n'.format('True' if use_xcode_managed_codesigning else 'False')
|
||||
string += 'telegram_bundle_id = "{}"\n'.format(self.bundle_id)
|
||||
string += 'telegram_api_id = "{}"\n'.format(self.api_id)
|
||||
string += 'telegram_api_hash = "{}"\n'.format(self.api_hash)
|
||||
@ -240,6 +241,9 @@ class CodesigningSource:
|
||||
raise Exception('Not implemented')
|
||||
|
||||
def resolve_aps_environment(self):
|
||||
raise Exception('Not implemented')
|
||||
|
||||
def use_xcode_managed_codesigning(self):
|
||||
raise Exception('Not implemented')
|
||||
|
||||
def copy_certificates_to_destination(self, destination_path):
|
||||
@ -280,6 +284,9 @@ class GitCodesigningSource(CodesigningSource):
|
||||
source_path = self.working_dir + '/decrypted/profiles/{}'.format(self.codesigning_type)
|
||||
return resolve_aps_environment_from_directory(source_path=source_path, team_id=self.team_id, bundle_id=self.bundle_id)
|
||||
|
||||
def use_xcode_managed_codesigning(self):
|
||||
return False
|
||||
|
||||
def copy_certificates_to_destination(self, destination_path):
|
||||
source_path = None
|
||||
if self.codesigning_type in ['adhoc', 'appstore']:
|
||||
@ -308,5 +315,28 @@ class DirectoryCodesigningSource(CodesigningSource):
|
||||
def resolve_aps_environment(self):
|
||||
return resolve_aps_environment_from_directory(source_path=self.directory_path + '/profiles', team_id=self.team_id, bundle_id=self.bundle_id)
|
||||
|
||||
def use_xcode_managed_codesigning(self):
|
||||
return False
|
||||
|
||||
def copy_certificates_to_destination(self, destination_path):
|
||||
copy_certificates_from_directory(source_path=self.directory_path + '/certs', destination_path=destination_path)
|
||||
|
||||
|
||||
class XcodeManagedCodesigningSource(CodesigningSource):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def load_data(self, working_dir):
|
||||
pass
|
||||
|
||||
def copy_profiles_to_destination(self, destination_path):
|
||||
pass
|
||||
|
||||
def resolve_aps_environment(self):
|
||||
return ""
|
||||
|
||||
def use_xcode_managed_codesigning(self):
|
||||
return True
|
||||
|
||||
def copy_certificates_to_destination(self, destination_path):
|
||||
pass
|
||||
|
@ -12,14 +12,15 @@ import glob
|
||||
from BuildEnvironment import resolve_executable, call_executable, run_executable_with_output, BuildEnvironment
|
||||
from ProjectGeneration import generate
|
||||
from BazelLocation import locate_bazel
|
||||
from BuildConfiguration import CodesigningSource, GitCodesigningSource, DirectoryCodesigningSource, BuildConfiguration, build_configuration_from_json
|
||||
from BuildConfiguration import CodesigningSource, GitCodesigningSource, DirectoryCodesigningSource, XcodeManagedCodesigningSource, BuildConfiguration, build_configuration_from_json
|
||||
import RemoteBuild
|
||||
import GenerateProfiles
|
||||
|
||||
|
||||
class ResolvedCodesigningData:
|
||||
def __init__(self, aps_environment):
|
||||
def __init__(self, aps_environment, use_xcode_managed_codesigning):
|
||||
self.aps_environment = aps_environment
|
||||
self.use_xcode_managed_codesigning = use_xcode_managed_codesigning
|
||||
|
||||
|
||||
class BazelCommandLine:
|
||||
@ -451,8 +452,8 @@ def resolve_codesigning(arguments, base_path, build_configuration, provisioning_
|
||||
team_id=build_configuration.team_id,
|
||||
bundle_id=build_configuration.bundle_id
|
||||
)
|
||||
elif arguments.noCodesigning is not None:
|
||||
return ResolvedCodesigningData(aps_environment='production')
|
||||
elif arguments.xcodeManagedCodesigning is not None and arguments.xcodeManagedCodesigning == True:
|
||||
profile_source = XcodeManagedCodesigningSource()
|
||||
else:
|
||||
raise Exception('Neither gitCodesigningRepository nor codesigningInformationPath are set')
|
||||
|
||||
@ -467,7 +468,10 @@ def resolve_codesigning(arguments, base_path, build_configuration, provisioning_
|
||||
profile_source.copy_profiles_to_destination(destination_path=additional_codesigning_output_path + '/profiles')
|
||||
profile_source.copy_certificates_to_destination(destination_path=additional_codesigning_output_path + '/certs')
|
||||
|
||||
return ResolvedCodesigningData(aps_environment=profile_source.resolve_aps_environment())
|
||||
return ResolvedCodesigningData(
|
||||
aps_environment=profile_source.resolve_aps_environment(),
|
||||
use_xcode_managed_codesigning=profile_source.use_xcode_managed_codesigning()
|
||||
)
|
||||
|
||||
|
||||
def resolve_configuration(base_path, bazel_command_line: BazelCommandLine, arguments, additional_codesigning_output_path):
|
||||
@ -499,7 +503,7 @@ def resolve_configuration(base_path, bazel_command_line: BazelCommandLine, argum
|
||||
sys.exit(1)
|
||||
|
||||
if bazel_command_line is not None:
|
||||
build_configuration.write_to_variables_file(bazel_path=bazel_command_line.bazel, aps_environment=codesigning_data.aps_environment, path=configuration_repository_path + '/variables.bzl')
|
||||
build_configuration.write_to_variables_file(bazel_path=bazel_command_line.bazel, use_xcode_managed_codesigning=codesigning_data.use_xcode_managed_codesigning, aps_environment=codesigning_data.aps_environment, path=configuration_repository_path + '/variables.bzl')
|
||||
|
||||
provisioning_profile_files = []
|
||||
for file_name in os.listdir(provisioning_path):
|
||||
@ -549,6 +553,8 @@ def generate_project(bazel, arguments):
|
||||
disable_extensions = arguments.disableExtensions
|
||||
if arguments.disableProvisioningProfiles is not None:
|
||||
disable_provisioning_profiles = arguments.disableProvisioningProfiles
|
||||
if arguments.xcodeManagedCodesigning is not None and arguments.xcodeManagedCodesigning == True:
|
||||
disable_extensions = True
|
||||
if arguments.generateDsym is not None:
|
||||
generate_dsym = arguments.generateDsym
|
||||
if arguments.target is not None:
|
||||
@ -594,9 +600,6 @@ def build(bazel, arguments):
|
||||
bazel_command_line.set_show_actions(arguments.showActions)
|
||||
bazel_command_line.set_enable_sandbox(arguments.sandbox)
|
||||
|
||||
if arguments.noCodesigning is not None:
|
||||
bazel_command_line.set_disable_provisioning_profiles()
|
||||
|
||||
bazel_command_line.set_split_swiftmodules(arguments.enableParallelSwiftmoduleGeneration)
|
||||
|
||||
bazel_command_line.invoke_build()
|
||||
@ -688,12 +691,11 @@ def add_codesigning_common_arguments(current_parser: argparse.ArgumentParser):
|
||||
metavar='command'
|
||||
)
|
||||
codesigning_group.add_argument(
|
||||
'--noCodesigning',
|
||||
type=bool,
|
||||
'--xcodeManagedCodesigning',
|
||||
action='store_true',
|
||||
help='''
|
||||
Use signing certificates and provisioning profiles from a local directory.
|
||||
Let Xcode manage your certificates and provisioning profiles.
|
||||
''',
|
||||
metavar='command'
|
||||
)
|
||||
|
||||
current_parser.add_argument(
|
||||
|
@ -10,21 +10,27 @@ def remove_directory(path):
|
||||
shutil.rmtree(path)
|
||||
|
||||
def generate_xcodeproj(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name):
|
||||
if '/' in target_name:
|
||||
app_target_spec = target_name.split('/')[0] + '/' + target_name.split('/')[1] + ':' + target_name.split('/')[1]
|
||||
app_target = target_name
|
||||
app_target_clean = app_target.replace('/', '_')
|
||||
else:
|
||||
app_target_spec = '{target}:{target}'.format(target=target_name)
|
||||
app_target = target_name
|
||||
app_target_clean = app_target.replace('/', '_')
|
||||
|
||||
bazel_generate_arguments = [build_environment.bazel_path]
|
||||
bazel_generate_arguments += ['run', '//Telegram:Telegram_xcodeproj']
|
||||
bazel_generate_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)]
|
||||
#if disable_extensions:
|
||||
# bazel_generate_arguments += ['--//{}:disableExtensions'.format(app_target)]
|
||||
#if disable_provisioning_profiles:
|
||||
# bazel_generate_arguments += ['--//{}:disableProvisioningProfiles'.format(app_target)]
|
||||
#if generate_dsym:
|
||||
# bazel_generate_arguments += ['--apple_generate_dsym']
|
||||
#bazel_generate_arguments += ['--//{}:disableStripping'.format('Telegram')]
|
||||
if disable_extensions:
|
||||
bazel_generate_arguments += ['--//{}:disableExtensions'.format(app_target)]
|
||||
|
||||
project_bazel_arguments = []
|
||||
for argument in bazel_app_arguments:
|
||||
project_bazel_arguments.append(argument)
|
||||
project_bazel_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)]
|
||||
if disable_extensions:
|
||||
project_bazel_arguments += ['--//{}:disableExtensions'.format(app_target)]
|
||||
|
||||
xcodeproj_bazelrc = os.path.join(build_environment.base_path, 'xcodeproj.bazelrc')
|
||||
if os.path.isfile(xcodeproj_bazelrc):
|
||||
|
14
build-system/template_minimal_development_configuration.json
Executable file
14
build-system/template_minimal_development_configuration.json
Executable file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"bundle_id": "org.{! a random string !}.Telegram",
|
||||
"api_id": "{! get one at https://my.telegram.org/apps !}",
|
||||
"api_hash": "{! get one at https://my.telegram.org/apps !}",
|
||||
"team_id": "{! check README.md !}",
|
||||
"app_center_id": "0",
|
||||
"is_internal_build": "true",
|
||||
"is_appstore_build": "false",
|
||||
"appstore_id": "0",
|
||||
"app_specific_url_scheme": "tg",
|
||||
"premium_iap_product_id": "",
|
||||
"enable_siri": false,
|
||||
"enable_icloud": false
|
||||
}
|
@ -7,6 +7,8 @@ load(
|
||||
"telegram_is_appstore_build",
|
||||
"telegram_appstore_id",
|
||||
"telegram_app_specific_url_scheme",
|
||||
"telegram_enable_icloud",
|
||||
"telegram_enable_siri",
|
||||
)
|
||||
|
||||
objc_library(
|
||||
@ -25,6 +27,8 @@ objc_library(
|
||||
"-DAPP_CONFIG_IS_APPSTORE_BUILD={}".format(telegram_is_appstore_build),
|
||||
"-DAPP_CONFIG_APPSTORE_ID={}".format(telegram_appstore_id),
|
||||
"-DAPP_SPECIFIC_URL_SCHEME=\\\"{}\\\"".format(telegram_app_specific_url_scheme),
|
||||
"-DAPP_CONFIG_IS_ICLOUD_ENABLED={}".format("true" if telegram_enable_icloud else "false"),
|
||||
"-DAPP_CONFIG_IS_SIRI_ENABLED={}".format("true" if telegram_enable_siri else "false"),
|
||||
],
|
||||
hdrs = glob([
|
||||
"PublicHeaders/**/*.h",
|
||||
|
@ -18,6 +18,8 @@
|
||||
@property (nonatomic, readonly) bool isAppStoreBuild;
|
||||
@property (nonatomic, readonly) int64_t appStoreId;
|
||||
@property (nonatomic, strong, readonly) NSString * _Nonnull appSpecificUrlScheme;
|
||||
@property (nonatomic, readonly) bool isICloudEnabled;
|
||||
@property (nonatomic, readonly) bool isSiriEnabled;
|
||||
|
||||
+ (DeviceSpecificEncryptionParameters * _Nonnull)deviceSpecificEncryptionParameters:(NSString * _Nonnull)rootPath baseAppBundleId:(NSString * _Nonnull)baseAppBundleId;
|
||||
- (NSData * _Nullable)bundleDataWithAppToken:(NSData * _Nullable)appToken signatureDict:(NSDictionary * _Nullable)signatureDict;
|
||||
|
@ -185,6 +185,14 @@ API_AVAILABLE(ios(10))
|
||||
return @(APP_SPECIFIC_URL_SCHEME);
|
||||
}
|
||||
|
||||
- (bool)isICloudEnabled {
|
||||
return APP_CONFIG_IS_ICLOUD_ENABLED;
|
||||
}
|
||||
|
||||
- (bool)isSiriEnabled {
|
||||
return APP_CONFIG_IS_SIRI_ENABLED;
|
||||
}
|
||||
|
||||
+ (NSString * _Nullable)bundleSeedId {
|
||||
NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
(__bridge NSString *)kSecClassGenericPassword, (__bridge NSString *)kSecClass,
|
||||
|
@ -434,8 +434,9 @@ public struct NetworkInitializationArguments {
|
||||
public let encryptionProvider: EncryptionProvider
|
||||
public let deviceModelName:String?
|
||||
public let useBetaFeatures: Bool
|
||||
public let isICloudEnabled: Bool
|
||||
|
||||
public init(apiId: Int32, apiHash: String, languagesCategory: String, appVersion: String, voipMaxLayer: Int32, voipVersions: [CallSessionManagerImplementationVersion], appData: Signal<Data?, NoError>, autolockDeadine: Signal<Int32?, NoError>, encryptionProvider: EncryptionProvider, deviceModelName: String?, useBetaFeatures: Bool) {
|
||||
public init(apiId: Int32, apiHash: String, languagesCategory: String, appVersion: String, voipMaxLayer: Int32, voipVersions: [CallSessionManagerImplementationVersion], appData: Signal<Data?, NoError>, autolockDeadine: Signal<Int32?, NoError>, encryptionProvider: EncryptionProvider, deviceModelName: String?, useBetaFeatures: Bool, isICloudEnabled: Bool) {
|
||||
self.apiId = apiId
|
||||
self.apiHash = apiHash
|
||||
self.languagesCategory = languagesCategory
|
||||
@ -447,6 +448,7 @@ public struct NetworkInitializationArguments {
|
||||
self.encryptionProvider = encryptionProvider
|
||||
self.deviceModelName = deviceModelName
|
||||
self.useBetaFeatures = useBetaFeatures
|
||||
self.isICloudEnabled = isICloudEnabled
|
||||
}
|
||||
}
|
||||
#if os(iOS)
|
||||
@ -541,7 +543,7 @@ func initializedNetwork(accountId: AccountRecordId, arguments: NetworkInitializa
|
||||
context.keychain = keychain
|
||||
var wrappedAdditionalSource: MTSignal?
|
||||
#if os(iOS)
|
||||
if #available(iOS 10.0, *), !supplementary {
|
||||
if #available(iOS 10.0, *), !supplementary, arguments.isICloudEnabled {
|
||||
var cloudDataContextValue: CloudDataContext?
|
||||
if let value = cloudDataContext.with({ $0 }) {
|
||||
cloudDataContextValue = value
|
||||
|
@ -483,7 +483,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
Logger.shared.log("data", "can't deserialize")
|
||||
}
|
||||
return data
|
||||
}, autolockDeadine: autolockDeadine, encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: !buildConfig.isAppStoreBuild)
|
||||
}, autolockDeadine: autolockDeadine, encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: !buildConfig.isAppStoreBuild, isICloudEnabled: buildConfig.isICloudEnabled)
|
||||
|
||||
guard let appGroupUrl = maybeAppGroupUrl else {
|
||||
self.mainWindow?.presentNative(UIAlertController(title: nil, message: "Error 2", preferredStyle: .alert))
|
||||
@ -752,8 +752,9 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
completion(false)
|
||||
}
|
||||
}, siriAuthorization: {
|
||||
if #available(iOS 10, *) {
|
||||
switch INPreferences.siriAuthorizationStatus() {
|
||||
if buildConfig.isSiriEnabled {
|
||||
if #available(iOS 10, *) {
|
||||
switch INPreferences.siriAuthorizationStatus() {
|
||||
case .authorized:
|
||||
return .allowed
|
||||
case .denied, .restricted:
|
||||
@ -762,6 +763,9 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
return .notDetermined
|
||||
@unknown default:
|
||||
return .notDetermined
|
||||
}
|
||||
} else {
|
||||
return .denied
|
||||
}
|
||||
} else {
|
||||
return .denied
|
||||
|
@ -140,7 +140,7 @@ public final class NotificationViewControllerImpl {
|
||||
return nil
|
||||
})
|
||||
|
||||
sharedAccountContext = SharedAccountContextImpl(mainWindow: nil, sharedContainerPath: self.initializationData.appGroupPath, basePath: rootPath, encryptionParameters: ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: self.initializationData.encryptionParameters.0)!, salt: ValueBoxEncryptionParameters.Salt(data: self.initializationData.encryptionParameters.1)!), accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: self.initializationData.apiId, apiHash: self.initializationData.apiHash, languagesCategory: self.initializationData.languagesCategory, appVersion: self.initializationData.appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(self.initializationData.bundleData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: self.initializationData.useBetaFeatures), hasInAppPurchases: false, rootPath: rootPath, legacyBasePath: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), firebaseSecretStream: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in }, appDelegate: nil)
|
||||
sharedAccountContext = SharedAccountContextImpl(mainWindow: nil, sharedContainerPath: self.initializationData.appGroupPath, basePath: rootPath, encryptionParameters: ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: self.initializationData.encryptionParameters.0)!, salt: ValueBoxEncryptionParameters.Salt(data: self.initializationData.encryptionParameters.1)!), accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: self.initializationData.apiId, apiHash: self.initializationData.apiHash, languagesCategory: self.initializationData.languagesCategory, appVersion: self.initializationData.appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(self.initializationData.bundleData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: self.initializationData.useBetaFeatures, isICloudEnabled: false), hasInAppPurchases: false, rootPath: rootPath, legacyBasePath: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), firebaseSecretStream: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in }, appDelegate: nil)
|
||||
|
||||
presentationDataPromise.set(sharedAccountContext!.presentationData)
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public class ShareRootControllerImpl {
|
||||
return nil
|
||||
})
|
||||
|
||||
let sharedContext = SharedAccountContextImpl(mainWindow: nil, sharedContainerPath: self.initializationData.appGroupPath, basePath: rootPath, encryptionParameters: ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: self.initializationData.encryptionParameters.0)!, salt: ValueBoxEncryptionParameters.Salt(data: self.initializationData.encryptionParameters.1)!), accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: self.initializationData.apiId, apiHash: self.initializationData.apiHash, languagesCategory: self.initializationData.languagesCategory, appVersion: self.initializationData.appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(self.initializationData.bundleData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: self.initializationData.useBetaFeatures), hasInAppPurchases: false, rootPath: rootPath, legacyBasePath: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), firebaseSecretStream: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in }, appDelegate: nil)
|
||||
let sharedContext = SharedAccountContextImpl(mainWindow: nil, sharedContainerPath: self.initializationData.appGroupPath, basePath: rootPath, encryptionParameters: ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: self.initializationData.encryptionParameters.0)!, salt: ValueBoxEncryptionParameters.Salt(data: self.initializationData.encryptionParameters.1)!), accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: NetworkInitializationArguments(apiId: self.initializationData.apiId, apiHash: self.initializationData.apiHash, languagesCategory: self.initializationData.languagesCategory, appVersion: self.initializationData.appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(self.initializationData.bundleData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), deviceModelName: nil, useBetaFeatures: self.initializationData.useBetaFeatures, isICloudEnabled: false), hasInAppPurchases: false, rootPath: rootPath, legacyBasePath: nil, apsNotificationToken: .never(), voipNotificationToken: .never(), firebaseSecretStream: .never(), setNotificationCall: { _ in }, navigateToChat: { _, _, _ in }, appDelegate: nil)
|
||||
presentationDataPromise.set(sharedContext.presentationData)
|
||||
internalContext = InternalContext(sharedContext: sharedContext)
|
||||
globalInternalContext = internalContext
|
||||
|
Loading…
x
Reference in New Issue
Block a user