mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-16 16:21:11 +00:00
Merge commit '6d7207bd069fd0275a046429ffdfcc9968f902c4'
This commit is contained in:
commit
3e9e90dd0a
@ -130,7 +130,7 @@ class ShareRootController: UIViewController {
|
||||
}, applicationInForeground: .single(false), applicationIsActive: .single(false), clearMessageNotifications: { _ in
|
||||
}, pushIdleTimerExtension: {
|
||||
return EmptyDisposable
|
||||
}, openSettings: {}, openAppStorePage: {}, registerForNotifications: { _ in }, getWindowHost: {
|
||||
}, openSettings: {}, openAppStorePage: {}, registerForNotifications: { _ in }, requestSiriAuthorization: { _ in }, siriAuthorization: { return .notDetermined }, getWindowHost: {
|
||||
return nil
|
||||
}, presentNativeController: { _ in
|
||||
}, dismissNativeController: {
|
||||
|
@ -602,6 +602,31 @@ private enum QueuedWakeup: Int32 {
|
||||
self.registerForNotifications(account: context.account, authorize: true, completion: completion)
|
||||
}
|
||||
})
|
||||
}, requestSiriAuthorization: { completion in
|
||||
if #available(iOS 10, *) {
|
||||
INPreferences.requestSiriAuthorization { status in
|
||||
if case .authorized = status {
|
||||
completion(true)
|
||||
} else {
|
||||
completion(false)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
completion(false)
|
||||
}
|
||||
}, siriAuthorization: {
|
||||
if #available(iOS 10, *) {
|
||||
switch INPreferences.siriAuthorizationStatus() {
|
||||
case .authorized:
|
||||
return .allowed
|
||||
case .denied, .restricted:
|
||||
return .denied
|
||||
case .notDetermined:
|
||||
return .notDetermined
|
||||
}
|
||||
} else {
|
||||
return .denied
|
||||
}
|
||||
}, getWindowHost: {
|
||||
return self.nativeWindow
|
||||
}, presentNativeController: { controller in
|
||||
|
@ -588,8 +588,6 @@ final class AuthorizedApplicationContext {
|
||||
}
|
||||
|
||||
if #available(iOS 10.0, *) {
|
||||
INPreferences.requestSiriAuthorization { _ in
|
||||
}
|
||||
} else {
|
||||
DeviceAccess.authorizeAccess(to: .contacts, presentationData: strongSelf.account.telegramApplicationContext.currentPresentationData.with { $0 }, present: { c, a in
|
||||
}, openSettings: {}, { _ in })
|
||||
@ -805,24 +803,28 @@ final class AuthorizedApplicationContext {
|
||||
|
||||
let permissionsPosition = ValuePromise(0, ignoreRepeated: true)
|
||||
self.permissionsDisposable.set((combineLatest(requiredPermissions(account: account), permissionUISplitTest(postbox: account.postbox), permissionsPosition.get(), account.postbox.combinedView(keys: [.noticeEntry(ApplicationSpecificNotice.contactsPermissionWarningKey()), .noticeEntry(ApplicationSpecificNotice.notificationsPermissionWarningKey())]))
|
||||
|> deliverOnMainQueue).start(next: { [weak self] contactsAndNotifications, splitTest, position, combined in
|
||||
|> deliverOnMainQueue).start(next: { [weak self] required, splitTest, position, combined in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
let contactsTimestamp = (combined.views[.noticeEntry(ApplicationSpecificNotice.contactsPermissionWarningKey())] as? NoticeEntryView)?.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) })
|
||||
let notificationsTimestamp = (combined.views[.noticeEntry(ApplicationSpecificNotice.notificationsPermissionWarningKey())] as? NoticeEntryView)?.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) })
|
||||
if contactsTimestamp == nil, case .requestable = contactsAndNotifications.0.status {
|
||||
if contactsTimestamp == nil, case .requestable = required.0.status {
|
||||
ApplicationSpecificNotice.setContactsPermissionWarning(postbox: account.postbox, value: 1)
|
||||
}
|
||||
if notificationsTimestamp == nil, case .requestable = contactsAndNotifications.1.status {
|
||||
if notificationsTimestamp == nil, case .requestable = required.1.status {
|
||||
ApplicationSpecificNotice.setNotificationsPermissionWarning(postbox: account.postbox, value: 1)
|
||||
}
|
||||
|
||||
let config = splitTest.configuration
|
||||
var order = config.order
|
||||
if !order.contains(.siri) {
|
||||
order.append(.siri)
|
||||
}
|
||||
var requestedPermissions: [(PermissionState, Bool)] = []
|
||||
var i: Int = 0
|
||||
for subject in config.order {
|
||||
for subject in order {
|
||||
if i < position {
|
||||
i += 1
|
||||
continue
|
||||
@ -833,15 +835,19 @@ final class AuthorizedApplicationContext {
|
||||
if case .modal = config.contacts {
|
||||
modal = true
|
||||
}
|
||||
if case .requestable = contactsAndNotifications.0.status, contactsTimestamp != 0 {
|
||||
requestedPermissions.append((contactsAndNotifications.0, modal || alwaysModal))
|
||||
if case .requestable = required.0.status, contactsTimestamp != 0 {
|
||||
requestedPermissions.append((required.0, modal || alwaysModal))
|
||||
}
|
||||
case .notifications:
|
||||
if case .modal = config.notifications {
|
||||
modal = true
|
||||
}
|
||||
if case .requestable = contactsAndNotifications.1.status, notificationsTimestamp != 0 {
|
||||
requestedPermissions.append((contactsAndNotifications.1, modal || alwaysModal))
|
||||
if case .requestable = required.1.status, notificationsTimestamp != 0 {
|
||||
requestedPermissions.append((required.1, modal || alwaysModal))
|
||||
}
|
||||
case .siri:
|
||||
if case .requestable = required.2.status {
|
||||
requestedPermissions.append((required.2, false))
|
||||
}
|
||||
default:
|
||||
break
|
||||
@ -903,6 +909,10 @@ final class AuthorizedApplicationContext {
|
||||
permissionsPosition.set(position + 1)
|
||||
ApplicationSpecificNotice.setNotificationsPermissionWarning(postbox: account.postbox, value: 0)
|
||||
}
|
||||
case .siri:
|
||||
DeviceAccess.authorizeAccess(to: .siri, account: account) { result in
|
||||
permissionsPosition.set(position + 1)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -910,8 +920,7 @@ final class AuthorizedApplicationContext {
|
||||
} else {
|
||||
if let controller = strongSelf.currentPermissionsController {
|
||||
strongSelf.currentPermissionsController = nil
|
||||
controller.dismiss(completion: {
|
||||
})
|
||||
controller.dismiss(completion: {})
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
@ -80,7 +80,7 @@ func snapshotEnvironment(application: UIApplication, mainWindow: UIWindow, statu
|
||||
}, openSettings: {
|
||||
}, openAppStorePage: {
|
||||
}, registerForNotifications: { _ in
|
||||
}, getWindowHost: {
|
||||
}, requestSiriAuthorization: { _ in }, siriAuthorization: { return .notDetermined }, getWindowHost: {
|
||||
return nil
|
||||
}, presentNativeController: { _ in
|
||||
}, dismissNativeController: {
|
||||
|
@ -3589,8 +3589,10 @@ Unused sets are archived when you add more.";
|
||||
"Contacts.PermissionsText" = "Please allow Telegram access to your phonebook to seamlessly find all your friends.";
|
||||
"Contacts.PermissionsAllow" = "Allow Access";
|
||||
"Contacts.PermissionsAllowInSettings" = "Allow in Settings";
|
||||
"Contacts.PermissionsSuppressWarningTitle" = "Are you sure you want to keep access to contacts disabled?";
|
||||
"Contacts.PermissionsSuppressWarningText" = "You can fine tune contacts sync in Settings > Privacy & Security > Data Settings.";
|
||||
"Contacts.PermissionsSuppressWarningTitle" = "Keep contacts disabled?";
|
||||
"Contacts.PermissionsSuppressWarningText" = "You won't know when your friends join Telegram and become available to chat. We recommend enabling access to contacts in Settings.";
|
||||
"Contacts.PermissionsKeepDisabled" = "Keep Disabled";
|
||||
"Contacts.PermissionsEnable" = "Enable";
|
||||
|
||||
"Notifications.PermissionsTitle" = "Turn ON Notifications";
|
||||
"Notifications.PermissionsText" = "Don't miss important messages from your friends and coworkers.";
|
||||
@ -3599,8 +3601,10 @@ Unused sets are archived when you add more.";
|
||||
"Notifications.PermissionsAllow" = "Turn Notifications ON";
|
||||
"Notifications.PermissionsAllowInSettings" = "Turn ON in Settings";
|
||||
"Notifications.PermissionsOpenSettings" = "Open Settings";
|
||||
"Notifications.PermissionsSuppressWarningTitle" = "Are you sure?";
|
||||
"Notifications.PermissionsSuppressWarningTitle" = "Keep notifications disabled?";
|
||||
"Notifications.PermissionsSuppressWarningText" = "You may miss important messages on Telegram due to your current settings.\n\nFor better results, enable alerts or banners and try muting certain chats or chat types in Telegram settings.";
|
||||
"Notifications.PermissionsKeepDisabled" = "Keep Disabled";
|
||||
"Notifications.PermissionsEnable" = "Enable";
|
||||
|
||||
"ChatSettings.DownloadInBackground" = "Background Download";
|
||||
"ChatSettings.DownloadInBackgroundInfo" = "The app will continue downloading media files for a limited time.";
|
||||
|
Loading…
x
Reference in New Issue
Block a user