I’m working on a Telegram bot and need help with something specific. I want to create an inline keyboard button that can launch a mobile app if it’s already installed on the user’s phone. Here’s what I have so far:
What should I put in the url field to make this work? I’m not sure if this is even possible with Telegram’s API. Can inline buttons actually trigger app launches on mobile devices? Any help would be great!
telegram handles this pretty well, but there’s another option worth trying. you can use the tg:// protocol for telegram-specific stuff or stick with deep links. i’ve had good luck with intent urls on android - something like intent://yourpath#Intent;scheme=yourapp;package=com.yourpackage;end handles fallbacks way better than regular custom schemes. just make sure your app’s set up to handle incoming urls in your activity or you’ll get crashes.
Custom URL schemes definitely work for this. I’ve used them in several projects. You need to register your app’s custom scheme first - that’s in the app manifest for Android or Info.plist for iOS. Once that’s done, your PHP code looks like: php $botKeyboard = [ 'inline_keyboard' => [ [ ['text' => 'Launch App', 'url' => 'yourappname://launch'] ] ] ]; Main issue is when users don’t have the app installed - they’ll just see an error. I usually add a second button that links to the app store as backup. Works great on both iOS and Android once you’ve got the scheme registered properly.
Yeah, you can do this with custom URL schemes. Just use your app’s scheme like myapp:// or myapp://open in the url field. The catch is fallbacks - Telegram won’t redirect to app stores if the scheme fails. I’ve done this before and universal links (iOS) or app links (Android) work way better than custom schemes. They look like regular HTTPS URLs but open the app if it’s installed, otherwise they hit your website. So instead of myapp://, you’d use https://yourapp.com/open set up as a universal/app link. Much more reliable since it handles both cases automatically.