Android: Telegram client searching for bot - android

I am working on a Telegram client (not a bot) plugin for an app to send messages in background to a bot. For this I am using the newest TDLib Api. All is working fine, when I already initiated a chat with the official Telegram App, where I searched for the Bot by name and started to communicate with him.
The problem is, that I don't know, how to search for a Bot over the Api. Or maybe there is another way to get the information to start a chat with a bot?

I found the solution:
First search for the bot by name:
TdApi.SearchPublicChat(mPrefs.getString(PreferenceKeys.BOT_NAME, "")
Then send the start message to the bot:
TdApi.SendBotStartMessage(mPrefs.getInt(PreferenceKeys.BOT_ID, 0), mPrefs.getInt(PreferenceKeys.MY_ID, 0), "" + System.currentTimeMillis())

Related

Telegram API integration for Android

I'm trying to read every Telegram channel message with my app. (I'm using Java)
I want to take the Image, description and links of every message.
Every Telegram message have a specific link like this:
https://t.me/example/**4091**
https://t.me/example/**4092**
https://t.me/example/**4093**
https://t.me/example/**4094**
Do you have any Idea to take all information from every single message?
thanks

Send push Notification in Ionic

I am working on an ionic application and need to implement push notifications using the back end API's developed in .NET.
While going through few blogs I found fire base API's and was able to complete a POC using Firebase. However the notification did not show when the app was in foreground.
I am not sure how to consume .NET API's to get the push messages. Can we achieve this without using Firebase. Please suggest. Thanks !
It is normal so that notification not show on forground using firebase notifications.
this.firebase.onNotificationOpen().subscribe( (msg) => {
if (this.platform.is('ios')) {
this.presentToast(msg.aps.alert);
//here notfication in ios
} else {
this.presentToast(msg.body);
//here notfication in android
}
});
This will trigger a toast of notification in foreground. If you want it as notfication, use local notfication and set the msg.body details as it should be shown inside the local notfication.
And as an advice, use onesignal notfication since it contains better features plus easier and more flexible.

Communicating with Facebook Messenger with API / Deeplink

I have an app which will, at some point, require Facebook Messenger to scan QR to connect with a bot.
I found two ways to scan a QR with messenger so far:
1-) Launch messenger and go to "People" tab and press "Scan QR" -> Scan the code
2-) Launch messenger, open camera, hold down to screen until circle appears -> Scan the code
What I want to do is to reduce the steps required to scan a QR code.
I couldn't see any proper solution by going through the Facebook Android SDK & Messenger Platform docs.
So my questions are:
1-) Is there any way to at least start the messenger with QR code reader on through deep link or with any official API ?
2-) Is there any other way to scan Facebook specific QR's ( circle ones ) outside of Messenger and launch messenger as a result ? ( launch a bot chat on Messenger with QR result )
P.S.: I know that deep links may deprecate / change without notice. Answer here also states it, but when I check, I see WizKid's answer here is from 2014. I'm asking this question to learn possible ways and if they added any official way to communicate with it.
If you want for it to be scanned with any reader, you can generate your own QR pointing to: https://m.me/{page_name}.
m.me is a shortened URL service operated by Facebook that redirects users to a person, page, or bot in Messenger. You can use them on your website, email newsletters, and more.
When a user starts a new conversation or continues an existing conversation with your bot via an m.me link, the following message will appear in the conversation: "You have entered this conversation by following a link. We've let PAGE_NAME know you're here."
The format of the link is http://m.me/{PAGE_NAME}, where PAGE_NAME is the handle of the Facebook page the bot is linked to.
This will in fact deep link into a conversation with your bot.
Additional documentation for this is available in https://developers.facebook.com/docs/messenger-platform/discovery/m-me-links

Push Notifications in WebView android app

I have a requirement where I want to send push notifications to the user.
For example
the app will have 2 users. If user 1 send a friend request to user 2
then user 2 should get a notification like " You got friend request
from user 1" and when user 2 clicks on that notification he should
able to see the user 1 profile.
I know how to do all these with the activities but here I am using web view, so please help me to solve with this. Any help is appreciable.
You can always access your Java code trough javascrtipt running on the web page your WebView is presenting. You can define a Java method (which sends the notification through your backend) and call it from your custom javascript.
Take a look at https://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object,%20java.lang.String)

Push Messages for PhoneGap

I created an app for iPhone and Android using Phonegap.
Now I wanted to add push functionality which already works pretty good.
When a push message arrives on my iPhone I get a message on the homescreen. If I swipe it, iOS will open my application. - So far so good.
Now, within my PhoneGap app I need to check what that message actually says in order to open the correct view within my app via JavaScript.
I know there are quite some posts about this but I couldn't find some clear answers to these questions:
Does PhoneGap support push messages?
If yes, where is the documentation for that?
If not, which plugins/frameworks can be recommended? So far I found pushwoosh and Urbanair. Are they any good?
Regarding Pushwoosh, I noticed that I need some kind of pushwoosh ID - Why that?
By Pushwoosh ID you most probably mean Pushwoosh App Id or Application Code. It's an ID of your application in Pushwoosh Control Panel (current format is XXXXX-XXXXX). You will see it as soon as you add a new app in Pushwoosh.
There was quite an extensive blog post made by Holly Schinsky on easy PhoneGap integration with Pushwoosh
http://devgirl.org/2012/12/04/easy-phonegap-push-notifications-with-pushwoosh/
It should be very helpful for all PhoneGap developers aiming to integrate push notifications into their apps.
I found a really easy solution without using a framework.
I simply added the following code to the very end of the method didFinishLaunchingWithOptions (Right before the return statement):
if (launchOptions != nil)
{
NSDictionary* dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (dictionary != nil)
{
NSLog(#"Launched from push notification: %#", dictionary);
[self addMessageFromRemoteNotification:dictionary updateUI:NO];
}
}
Also, I added this new method to my AppDelegate.m which gets the payload from the push message:
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
NSLog(#"Received notification: %#", userInfo);
[self addMessageFromRemoteNotification:userInfo updateUI:YES];
}
(The NSLog calls above will show you what's inside the push message)
As a last step, I added this listener to do what ever I want with the payload:
- (void)addMessageFromRemoteNotification:(NSDictionary*)userInfo updateUI:(BOOL)updateUI
{
// do what ever you want with userInfo
}
If you want to do an additional JavaScript call with this info, I recommend using:
[self.viewController.webView stringByEvaluatingJavaScriptFromString:#"callSomeJSFunction()"];
Of course you can also pass arguments as strings into that JS function if you want.

Categories

Resources