Skip to content

Commit

Permalink
support telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
李卓原 committed Sep 17, 2021
1 parent f84502c commit 1dbc31d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,15 @@ private void shareWhatsApp(String imagePath, String msg, Result result, boolean

private void shareToTelegram(String msg, Result result) {
try {
String message = call.argument("msg");
Intent telegramIntent = new Intent(Intent.ACTION_SEND);
telegramIntent.setType("text/plain");
telegramIntent.setPackage("org.telegram.messenger");
telegramIntent.putExtra(Intent.EXTRA_TEXT, message);
telegramIntent.putExtra(Intent.EXTRA_TEXT, msg);
try {
startActivity(telegramIntent);
activity.startActivity(telegramIntent);
result.success("true");
} catch (Exception ex) {
result.success("false");
result.success("false:Telegram app is not installed on your device");
}
} catch (Exception var9) {
result.error("error", var9.toString(), "");
Expand Down
1 change: 1 addition & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<string>343254889799245</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tg</string>
<string>instagram</string>
<string>twitter</string>
<string>fbauth2</string>
Expand Down
4 changes: 2 additions & 2 deletions ios/Classes/SwiftFlutterShareMePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class SwiftFlutterShareMePlugin: NSObject, FlutterPlugin, SharingDelegate
}
else if(call.method.elementsEqual(_methodTelegramShare)){
let args = call.arguments as? Dictionary<String,Any>
shareToTelegram(message: args!["msg"] as! String )
shareToTelegram(message: args!["msg"] as! String, result: result )
}
else{
let args = call.arguments as? Dictionary<String,Any>
Expand Down Expand Up @@ -238,7 +238,7 @@ public class SwiftFlutterShareMePlugin: NSObject, FlutterPlugin, SharingDelegate
}
else
{
result(FlutterError(code: "Not found", message: "WhatsAppBusiness is not found", details: "WhatsAppBusiness not intalled or Check url scheme."));
result(FlutterError(code: "Not found", message: "telegram is not found", details: "telegram not intalled or Check url scheme."));
}

}
Expand Down

0 comments on commit 1dbc31d

Please sign in to comment.