mirror of
https://github.com/danog/Telegram.git
synced 2024-12-03 09:57:46 +01:00
35 lines
1.2 KiB
Objective-C
35 lines
1.2 KiB
Objective-C
#import "TGAccessRequiredAlertView.h"
|
|
|
|
@implementation TGAccessRequiredAlertView
|
|
|
|
- (instancetype)initWithMessage:(NSString *)message showSettingsButton:(bool)showSettingsButton completionBlock:(void (^)(void))completionBlock
|
|
{
|
|
if (iosMajorVersion() < 8 || !showSettingsButton)
|
|
{
|
|
return [super initWithTitle:TGLocalized(@"AccessDenied.Title") message:message cancelButtonTitle:TGLocalized(@"Common.OK") okButtonTitle:nil completionBlock:^(__unused bool okButtonPressed)
|
|
{
|
|
if (completionBlock != nil)
|
|
completionBlock();
|
|
}];
|
|
}
|
|
else
|
|
{
|
|
return [super initWithTitle:TGLocalized(@"AccessDenied.Title") message:message cancelButtonTitle:TGLocalized(@"Common.OK") otherButtonTitles:@[ TGLocalized(@"AccessDenied.Settings") ] completionBlock:^(bool settingsButtonPressed)
|
|
{
|
|
if (settingsButtonPressed)
|
|
[TGAccessRequiredAlertView openSettings];
|
|
|
|
if (completionBlock != nil)
|
|
completionBlock();
|
|
}];
|
|
}
|
|
}
|
|
|
|
+ (void)openSettings
|
|
{
|
|
if (&UIApplicationOpenSettingsURLString != NULL)
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
}
|
|
|
|
@end
|