diff --git a/data/core.telegram.org/passport/sdk-ios-mac.html b/data/core.telegram.org/passport/sdk-ios-mac.html new file mode 100644 index 0000000000..05aa14d5ed --- /dev/null +++ b/data/core.telegram.org/passport/sdk-ios-mac.html @@ -0,0 +1,246 @@ + + +
+ +TGPassportKit helps you easily integrate Telegram Passport requests into your iOS & macOS apps. Check out our GitHub repository to see samples using this SDK.
+To install TGPassportKit via Cocoapods add the following to your Podfile:
+target 'MyApp' do
+ pod 'TGPassportKit'
+end
+then run pod install
in your project root directory.
Add the following line to your Cartfile:
+github "telegrammessenger/TGPassportKit"
+then run carthage update
, and you will get the latest version of TGPassportKit in your Carthage folder.
Configure your Info.plist by right-clicking it in Project Navigator, choosing Open As > Source Code and adding this snippet:
+Replace {bot_id}
with your value
<key>CFBundleURLTypes</key>
+<array>
+ <dict>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>tgbot{bot_id}</string>
+ </array>
+ </dict>
+</array>
+<key>LSApplicationQueriesSchemes</key>
+<array>
+ <string>tg</string>
+</array>
+Add this code to your UIApplicationDelegate
implementation
#import <TGPassportKit/TGPAppDelegate.h>
+
+- (BOOL)application:(UIApplication *)application
+ openURL:(NSURL *)url
+ options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
+ BOOL handledByPassportKit = [[TGPAppDelegate sharedDelegate] application:application
+ openURL:url
+ options:options];
+
+ return YES;
+}
+If you support iOS 9 and below, also add this method:
+- (BOOL)application:(UIApplication *)application
+ openURL:(NSURL *)url
+ sourceApplication:(nullable NSString *)sourceApplication
+ annotation:(id)annotation {
+ BOOL handledByPassportKit = [[TGPAppDelegate sharedDelegate] application:application
+ openURL:url
+ sourceApplication:sourceApplication
+ annotation:annotation];
+
+ return YES;
+}
+To add the Telegram Passport button, add the following code to your view controller:
+Replace {bot_id}
, {bot_public_key}
and {request_nonce}
with your values
#import <TGPassportKit/TGPButton.h>
+
+@interface ViewController <TGPButtonDelegate>
+
+@end
+
+@implementation ViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ TGPButton *button = [[TGPButton alloc] init];
+ button.botConfig = [[TGPBotConfig alloc] initWithBotId:{bot_id}
+ publicKey:@"{bot_public_key}"];
+ button.scope = [[TGPScope alloc] initWithJSONString:@"{\"data\":[\"id_document\",\"address_document\",\"phone_number\"],\"v\":1}"];
+// You can also construct a scope using provided data type classes like this:
+// button.scope = [[TGPScope alloc] initWithTypes:@[[[TGPPersonalDetails alloc] init], [[TGPIdentityDocument alloc] initWithType:TGPIdentityDocumentTypePassport selfie:true translation:true]]];
+ button.nonce = @"{request_nonce}";
+ button.delegate = self;
+ [self.view addSubview:button];
+}
+
+- (void)passportButton:(TGPButton *)passportButton
+ didCompleteWithResult:(TGPRequestResult)result
+ error:(NSError *)error {
+ switch (result) {
+ case TGPRequestResultSucceed:
+ NSLog(@"Succeed");
+ break;
+
+ case TGPRequestResultCancelled:
+ NSLog(@"Cancelled");
+ break;
+
+ default:
+ NSLog(@"Failed");
+ break;
+ }
+}
+
+@end
+If you want to design a custom UI and behavior, you can invoke a Passport request like this:
+Replace {bot_id}
, {bot_public_key}
and {request_nonce}
with your values
#import <TGPassportKit/TGPRequest.h>
+
+- (void)performPassportRequest
+{
+ TGPBotConfig *botConfig = [[TGPBotConfig alloc] initWithBotId:{bot_id}
+ publicKey:@"{bot_public_key}"];
+ TGPRequest *request = [[TGPRequest alloc] initWithBotConfig:botConfig];
+ [request performWithScope:[[TGPScope alloc] initWithJSONString:@"{\"data\":[\"id_document\",\"phone_number\"],\"v\":1}"]
+ payload:@"{request_nonce}"
+ completionHandler:^(TGPRequestResult result, NSError * _Nullable error) {
+ switch (result) {
+ case TGPRequestResultSucceed:
+ NSLog(@"Succeed");
+ break;
+
+ case TGPRequestResultCancelled:
+ NSLog(@"Cancelled");
+ break;
+
+ default:
+ NSLog(@"Failed");
+ break;
+ }
+ }];
+}
Farewell to typos! Starting today, you can edit the text of your messages after sending them. This works across all Telegram chats, including groups and one-on-one conversations.
+ + +Simply tap and hold on a message, then press ‘Edit’. If you're on desktop, press the up arrow button to edit your last message. The messages will display a small ‘edited’ label so that it's easy to tell which were altered.
+Mentioning other people in groups is handy since it sends them a notification about your message even if they muted the group. Starting today, you can mention any members in a group – even if they don't have a username. Just type the @
symbol and select whoever you would like to address. Easy!
Speaking of addressing people, you can now get to your recent chats much faster using the new People list in Search.
+ + + +We've also made it easier for you to access your favorite inline bots. Simply scroll down the attachment menu – and there they are. The more you use them, the higher they will climb.
+ + +Naturally, you will only see inline bots in the attachment menu if you used them at least once. Try @youtube, @gif or @imdb if you don't know where to start. Check out this post for more info on how to use inline bots.
+We‘ve added quick sharing buttons to forwarded messages from bots, channels, and public groups. Notifications about messages with stickers will now show the relevant emoji so that you’ll know the general idea at first glance.
+ + +Last but not least, if you're on iOS, your app now remembers the scroll position in chats when switching to a different chat and back. And scrolling up in a chat summons a new button that will send you back to the bottom in one tap. This button also displays a handy unread message counter if new ones are waiting for you there.
+And that's it for today. Stay tuned for more updates coming soon!
+May 15, 2016
The Telegram Team