diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml new file mode 100644 index 0000000..d9b2670 --- /dev/null +++ b/.idea/libraries/Dart_SDK.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 4ce8a6e..8d88619 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -35,6 +35,5 @@ android { } dependencies { - implementation 'com.facebook.android:facebook-share:5.15.3' - implementation 'com.twitter.sdk.android:twitter:3.1.1' //twitter share + implementation 'com.facebook.android:facebook-share:17.0.0' } diff --git a/android/src/main/java/zhuoyuan/li/fluttershareme/FlutterShareMePlugin.java b/android/src/main/java/zhuoyuan/li/fluttershareme/FlutterShareMePlugin.java index d261c35..76f5825 100644 --- a/android/src/main/java/zhuoyuan/li/fluttershareme/FlutterShareMePlugin.java +++ b/android/src/main/java/zhuoyuan/li/fluttershareme/FlutterShareMePlugin.java @@ -8,6 +8,8 @@ import android.net.Uri; import android.text.TextUtils; import android.util.Log; +import android.content.pm.ResolveInfo; +import android.os.Parcelable; import androidx.annotation.NonNull; import androidx.core.content.FileProvider; @@ -17,14 +19,16 @@ import com.facebook.FacebookException; import com.facebook.share.Sharer; import com.facebook.share.model.ShareLinkContent; +import com.facebook.share.widget.MessageDialog; import com.facebook.share.widget.ShareDialog; -import com.twitter.sdk.android.tweetcomposer.TweetComposer; import java.io.File; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.List; import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.embedding.engine.plugins.activity.ActivityAware; @@ -44,10 +48,17 @@ public class FlutterShareMePlugin implements MethodCallHandler, FlutterPlugin, A final private static String _methodWhatsApp = "whatsapp_share"; final private static String _methodWhatsAppPersonal = "whatsapp_personal"; final private static String _methodWhatsAppBusiness = "whatsapp_business_share"; + final private static String _methodFaceBook = "facebook_share"; + final private static String _methodMessenger = "messenger_share"; + final private static String _methodTwitter = "twitter_share"; + final private static String _methodSystemShare = "system_share"; + final private static String _methodInstagramShare = "instagram_share"; + final private static String _methodInstagramShareText = "instagram_share_text"; + final private static String _methodTelegramShare = "telegram_share"; @@ -90,17 +101,20 @@ private void onAttachedToEngine(BinaryMessenger messenger) { */ @Override public void onMethodCall(MethodCall call, @NonNull Result result) { - String url, msg; + String url, msg, fileType; switch (call.method) { case _methodFaceBook: url = call.argument("url"); msg = call.argument("msg"); shareToFacebook(url, msg, result); break; + case _methodMessenger: + msg = call.argument("msg"); + shareToMessenger( msg, result); + break; case _methodTwitter: - url = call.argument("url"); msg = call.argument("msg"); - shareToTwitter(url, msg, result); + shareToTwitter(msg, result); break; case _methodWhatsApp: msg = call.argument("msg"); @@ -123,7 +137,12 @@ public void onMethodCall(MethodCall call, @NonNull Result result) { break; case _methodInstagramShare: msg = call.argument("url"); - shareInstagramStory(msg, result); + fileType = call.argument("fileType"); + shareInstagramStory(msg, fileType, result); + break; + case _methodInstagramShareText: + msg = call.argument("msg"); + shareInstagramText(msg, result); break; case _methodTelegramShare: msg = call.argument("msg"); @@ -156,23 +175,48 @@ private void shareSystem(Result result, String msg) { /** * share to twitter * - * @param url String * @param msg String * @param result Result */ + private void shareToTwitter(String msg, Result result) { + if (twitterInstalled()) { + List targetedShareIntents = new ArrayList(); - private void shareToTwitter(String url, String msg, Result result) { - try { - TweetComposer.Builder builder = new TweetComposer.Builder(activity) - .text(msg); - if (url != null && url.length() > 0) { - builder.url(new URL(url)); + Intent textIntent = new Intent(Intent.ACTION_SEND); + textIntent.setType("text/plain"); + textIntent.putExtra(Intent.EXTRA_TEXT, msg); + + List resInfo = activity.getPackageManager().queryIntentActivities(textIntent, 0); + + for (ResolveInfo resolveInfo : resInfo) { + String packageName = resolveInfo.activityInfo.packageName; + + Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND); + targetedShareIntent.setType("text/plain"); + targetedShareIntent.putExtra(Intent.EXTRA_TEXT, msg); + targetedShareIntent.setPackage(packageName); + + if (packageName.equals("com.twitter.android")) { // Add only instagram + targetedShareIntents.add(targetedShareIntent); + } } - builder.show(); - result.success("success"); - } catch (MalformedURLException e) { - e.printStackTrace(); + Intent chooserIntent = Intent.createChooser( + targetedShareIntents.remove(0), "Select how to share"); + + chooserIntent.putExtra( + Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{})); + + try { + activity.startActivity(chooserIntent); + result.success("Success"); + } catch (ActivityNotFoundException e) { + e.printStackTrace(); + result.success("Failure"); + } + + } else { + result.error("Twitter not found", "Twitter is not installed on device.", ""); } } @@ -215,6 +259,53 @@ public void onError(FacebookException error) { } + /** + * share to Messenger + * + * @param msg String + * @param result Result + */ + private void shareToMessenger(String msg, Result result) { + if (messengerInstalled()) { + List targetedShareIntents = new ArrayList(); + + Intent textIntent = new Intent(Intent.ACTION_SEND); + textIntent.setType("text/plain"); + textIntent.putExtra(Intent.EXTRA_TEXT, msg); + + List resInfo = activity.getPackageManager().queryIntentActivities(textIntent, 0); + + for (ResolveInfo resolveInfo : resInfo) { + String packageName = resolveInfo.activityInfo.packageName; + + Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND); + targetedShareIntent.setType("text/plain"); + targetedShareIntent.putExtra(Intent.EXTRA_TEXT, msg); + targetedShareIntent.setPackage(packageName); + + if (packageName.equals("com.facebook.orca")) { // Add only instagram + targetedShareIntents.add(targetedShareIntent); + } + } + + Intent chooserIntent = Intent.createChooser( + targetedShareIntents.remove(0), "Select how to share"); + + chooserIntent.putExtra( + Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{})); + + try { + activity.startActivity(chooserIntent); + result.success("Success"); + } catch (ActivityNotFoundException e) { + e.printStackTrace(); + result.success("Failure"); + } + + } else { + result.error("Messenger not found", "Messenger is not installed on device.", ""); + } + } /** * share to whatsapp * @@ -294,16 +385,20 @@ private void shareWhatsAppPersonal(String msg, String phoneNumber, Result result /** * share to instagram * - * @param url local image path - * @param result flutterResult + * @param url local file path + * @param fileType type of file to share (image or video) + * @param result flutterResult */ - private void shareInstagramStory(String url, Result result) { + private void shareInstagramStory(String url, String fileType, Result result) { if (instagramInstalled()) { File file = new File(url); Uri fileUri = FileProvider.getUriForFile(activity, activity.getApplicationContext().getPackageName() + ".provider", file); Intent instagramIntent = new Intent(Intent.ACTION_SEND); - instagramIntent.setType("image/*"); + if(fileType.equals("image")) + instagramIntent.setType("image/*"); + else if(fileType.equals("video")) + instagramIntent.setType("video/*"); instagramIntent.putExtra(Intent.EXTRA_STREAM, fileUri); instagramIntent.setPackage("com.instagram.android"); try { @@ -318,6 +413,53 @@ private void shareInstagramStory(String url, Result result) { } } + private void shareInstagramText(String msg, Result result) { + if (instagramInstalled()) { + List targetedShareIntents = new ArrayList(); + + Intent textIntent = new Intent(Intent.ACTION_SEND); + textIntent.setType("text/plain"); + textIntent.putExtra(Intent.EXTRA_TEXT, msg); + + List resInfo = activity.getPackageManager().queryIntentActivities(textIntent, 0); + + for (ResolveInfo resolveInfo : resInfo) { + String packageName = resolveInfo.activityInfo.packageName; + + Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND); + targetedShareIntent.setType("text/plain"); + targetedShareIntent.putExtra(Intent.EXTRA_TEXT, msg); + targetedShareIntent.setPackage(packageName); + + if (packageName.equals("com.instagram.android")) { // Add only instagram + targetedShareIntents.add(targetedShareIntent); + } + } + + //Intent i = new Intent(this); + //targetedShareIntents.add(i); + + Intent chooserIntent = Intent.createChooser( + targetedShareIntents.remove(0), "Select how to share"); + + chooserIntent.putExtra( + Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{})); + + try { + activity.startActivity(chooserIntent); + result.success("Success"); + } catch (ActivityNotFoundException e) { + e.printStackTrace(); + result.success("Failure"); + } + + + + } else { + result.error("Instagram not found", "Instagram is not installed on device.", ""); + } + } + @Override public void onAttachedToActivity(ActivityPluginBinding binding) { activity = binding.getActivity(); @@ -352,6 +494,38 @@ private boolean instagramInstalled() { } catch (PackageManager.NameNotFoundException e) { return false; } +// return false; + } + + private boolean twitterInstalled() { + try { + if (activity != null) { + activity.getPackageManager() + .getApplicationInfo("com.twitter.android", 0); + return true; + } else { + Log.d("App", "Twitter app is not installed on your device"); + return false; + } + } catch (PackageManager.NameNotFoundException e) { + return false; + } +// return false; + } + + private boolean messengerInstalled() { + try { + if (activity != null) { + activity.getPackageManager() + .getApplicationInfo("com.facebook.orca", 0); + return true; + } else { + Log.d("App", "Messenger app is not installed on your device"); + return false; + } + } catch (PackageManager.NameNotFoundException e) { + return false; + } // return false; } } diff --git a/example/android/app/src/main/kotlin/zhuoyuan/li/example/MainActivity.kt b/example/android/app/src/main/kotlin/zhuoyuan/li/example/MainActivity.kt new file mode 100644 index 0000000..6cb1dde --- /dev/null +++ b/example/android/app/src/main/kotlin/zhuoyuan/li/example/MainActivity.kt @@ -0,0 +1,6 @@ +package zhuoyuan.li.example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9367d48 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 8.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 252d9ec..1e8c3c9 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '9.0' +# platform :ios, '9.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..6ce66c3 --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,551 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 2C19018BE1867239E229330F /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22900EE5F15C5949E20D437B /* Pods_Runner.framework */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 186585A880F95519003B2B0F /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 22900EE5F15C5949E20D437B /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A2916A22C5D329285B7B21FC /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + EC452A4EB1D663B67BCA7ACA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C19018BE1867239E229330F /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 453592400F7523B5AFCADB41 /* Pods */ = { + isa = PBXGroup; + children = ( + EC452A4EB1D663B67BCA7ACA /* Pods-Runner.debug.xcconfig */, + A2916A22C5D329285B7B21FC /* Pods-Runner.release.xcconfig */, + 186585A880F95519003B2B0F /* Pods-Runner.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 453592400F7523B5AFCADB41 /* Pods */, + ABD678321BABAE0426324B26 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; + ABD678321BABAE0426324B26 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 22900EE5F15C5949E20D437B /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 4C172AD073A2875F05C878E5 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ADA258E442DF3D43FF39D702 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 4C172AD073A2875F05C878E5 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + ADA258E442DF3D43FF39D702 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = CS942AL422; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = zhuoyuan.li.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = CS942AL422; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = zhuoyuan.li.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = CS942AL422; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = zhuoyuan.li.example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index 72a80d2..70693e4 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -8,7 +8,6 @@ import Flutter didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) } } diff --git a/example/lib/generated_plugin_registrant.dart b/example/lib/generated_plugin_registrant.dart new file mode 100644 index 0000000..d09f94d --- /dev/null +++ b/example/lib/generated_plugin_registrant.dart @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// ignore_for_file: lines_longer_than_80_chars + +import 'package:image_picker_for_web/image_picker_for_web.dart'; + +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +// ignore: public_member_api_docs +void registerPlugins(Registrar registrar) { + ImagePickerPlugin.registerWith(registrar); + registrar.registerMessageHandler(); +} diff --git a/example/web/favicon.png b/example/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/example/web/favicon.png differ diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/example/web/icons/Icon-192.png differ diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/example/web/icons/Icon-512.png differ diff --git a/example/web/index.html b/example/web/index.html new file mode 100644 index 0000000..0081e18 --- /dev/null +++ b/example/web/index.html @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + example + + + + + + + diff --git a/example/web/manifest.json b/example/web/manifest.json new file mode 100644 index 0000000..8c01291 --- /dev/null +++ b/example/web/manifest.json @@ -0,0 +1,23 @@ +{ + "name": "example", + "short_name": "example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/ios/Classes/SwiftFlutterShareMePlugin.swift b/ios/Classes/SwiftFlutterShareMePlugin.swift index b05594a..aed3e45 100644 --- a/ios/Classes/SwiftFlutterShareMePlugin.swift +++ b/ios/Classes/SwiftFlutterShareMePlugin.swift @@ -64,7 +64,7 @@ public class SwiftFlutterShareMePlugin: NSObject, FlutterPlugin, SharingDelegate }else if(call.method.elementsEqual(_methodTwitter)){ let args = call.arguments as? Dictionary - shareTwitter(message: args!["msg"] as! String, url: args!["url"] as! String, result: result) + shareTwitter(message: args!["msg"] as! String, result: result) } else if(call.method.elementsEqual(_methodInstagram)){ let args = call.arguments as? Dictionary @@ -113,7 +113,7 @@ public class SwiftFlutterShareMePlugin: NSObject, FlutterPlugin, SharingDelegate result("File format not supported Please check the file.") return; } - urlData=(image?.jpegData(compressionQuality: 1.0))! + urlData=(image!.jpegData(compressionQuality: 1.0))! filePath=URL(fileURLWithPath:NSHomeDirectory()).appendingPathComponent("Documents/whatsAppTmp.wai") }else{ filePath=URL(fileURLWithPath:NSTemporaryDirectory()).appendingPathComponent("video.m4v") @@ -180,18 +180,19 @@ public class SwiftFlutterShareMePlugin: NSObject, FlutterPlugin, SharingDelegate result(FlutterError(code: "Not found", message: "WhatsAppBusiness is not found", details: "WhatsAppBusiness not intalled or Check url scheme.")); } } - // share twitter + // share facebook // params // @ map conting meesage and url func sharefacebook(message:Dictionary, result: @escaping FlutterResult) { let viewController = UIApplication.shared.delegate?.window??.rootViewController - let shareDialog=ShareDialog() + let shareContent = ShareLinkContent() shareContent.contentURL = URL.init(string: message["url"] as! String)! shareContent.quote = message["msg"] as? String + let shareDialog = ShareDialog(viewController: viewController, content: shareContent, delegate: self) shareDialog.mode = .automatic - ShareDialog(fromViewController: viewController, content: shareContent, delegate: self).show() + shareDialog.show(); result("Sucess") } @@ -199,16 +200,9 @@ public class SwiftFlutterShareMePlugin: NSObject, FlutterPlugin, SharingDelegate // share twitter params // @ message // @ url - func shareTwitter(message:String,url:String, result: @escaping FlutterResult) { - let urlstring = url + func shareTwitter(message:String, result: @escaping FlutterResult) { let twitterUrl = "twitter://post?message=\(message)" - - let urlTextEscaped = urlstring.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed) - let url = URL(string: urlTextEscaped ?? "") - - let urlWithLink = twitterUrl + url!.absoluteString - - let escapedShareString = urlWithLink.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)! + let escapedShareString = twitterUrl.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)! // cast to an url let urlschme = URL(string: escapedShareString) // open in safari diff --git a/lib/flutter_share_me.dart b/lib/flutter_share_me.dart index 1c70509..d9657c5 100644 --- a/lib/flutter_share_me.dart +++ b/lib/flutter_share_me.dart @@ -12,18 +12,22 @@ class FlutterShareMe { static const String _methodWhatsAppPersonal = 'whatsapp_personal'; static const String _methodWhatsAppBusiness = 'whatsapp_business_share'; static const String _methodFaceBook = 'facebook_share'; + static const String _methodMessenger = 'messenger_share'; static const String _methodTwitter = 'twitter_share'; static const String _methodInstagramShare = 'instagram_share'; + static const String _methodInstagramShareText = 'instagram_share_text'; static const String _methodSystemShare = 'system_share'; static const String _methodTelegramShare = 'telegram_share'; - ///share to WhatsApp - /// [imagePath] is local image + /// share to WhatsApp + /// [imagePath] is local image file path /// [phoneNumber] enter phone number with counry code /// For ios /// If include image then text params will be ingored as there is no current way in IOS share both at the same. Future shareToWhatsApp( - {String msg = '', String imagePath = '', FileType? fileType = FileType.image}) async { + {String msg = '', + String imagePath = '', + FileType? fileType = FileType.image}) async { final Map arguments = {}; arguments.putIfAbsent('msg', () => msg); arguments.putIfAbsent('url', () => imagePath); @@ -43,7 +47,7 @@ class FlutterShareMe { return result; } - ///share to WhatsApp + /// share to WhatsApp contact /// [phoneNumber] phone number with counry code /// [msg] message text you want on whatsapp Future shareWhatsAppPersonalMessage( @@ -54,40 +58,42 @@ class FlutterShareMe { String? result; try { - result = await _channel.invokeMethod(_methodWhatsAppPersonal, arguments); + result = await _channel.invokeMethod( + _methodWhatsAppPersonal, arguments); } catch (e) { return e.toString(); } return result; } - ///share to Telegram + + /// share to Telegram /// [msg] message text you want on telegram - Future shareToTelegram( - {required String msg}) async { + Future shareToTelegram({required String msg}) async { final Map arguments = {}; arguments.putIfAbsent('msg', () => msg); String? result; try { - result = await _channel.invokeMethod(_methodTelegramShare, arguments); + result = + await _channel.invokeMethod(_methodTelegramShare, arguments); } catch (e) { return e.toString(); } return result; } - ///share to WhatsApp4Biz - ///[imagePath] is local image - /// For ios - /// If include image then text params will be ingored as there is no current way in IOS share both at the same. - Future shareToWhatsApp4Biz({String msg = '', String? imagePath = ''}) async { + /// share to WhatsApp4Biz [Android Only] + /// [imagePath] is local image file path + Future shareToWhatsApp4Biz( + {String msg = '', String? imagePath = ''}) async { final Map arguments = {}; arguments.putIfAbsent('msg', () => msg); arguments.putIfAbsent('url', () => imagePath); String? result; try { - result = await _channel.invokeMethod(_methodWhatsAppBusiness, arguments); + result = await _channel.invokeMethod( + _methodWhatsAppBusiness, arguments); } catch (e) { return 'false'; } @@ -95,8 +101,9 @@ class FlutterShareMe { return result; } - ///share to facebook - Future shareToFacebook({required String msg, String url = ''}) async { + /// share to facebook + Future shareToFacebook( + {required String msg, String url = ''}) async { final Map arguments = {}; arguments.putIfAbsent('msg', () => msg); arguments.putIfAbsent('url', () => url); @@ -109,40 +116,77 @@ class FlutterShareMe { return result; } - ///share to twitter - ///[msg] string that you want share. - Future shareToTwitter({required String msg, String url = ''}) async { + /// share to messenger [Android only] + Future shareToMessenger({required String msg}) async { + final Map arguments = {}; + arguments.putIfAbsent('msg', () => msg); + String? result; + try { + result = await _channel.invokeMethod(_methodMessenger, arguments); + } catch (e) { + return e.toString(); + } + return result; + } + + /// share to twitter + /// [msg] string that you want share. + Future shareToTwitter({required String msg}) async { final Map arguments = {}; arguments.putIfAbsent('msg', () => msg); - arguments.putIfAbsent('url', () => url); String? result; try { - result = await _channel.invokeMethod(_methodTwitter, arguments); + result = await _channel.invokeMethod(_methodTwitter, arguments); } catch (e) { return e.toString(); } return result; } - ///use system share ui + /// use system share ui Future shareToSystem({required String msg}) async { String? result; try { - result = await _channel.invokeMethod(_methodSystemShare, {'msg': msg}); + result = + await _channel.invokeMethod(_methodSystemShare, {'msg': msg}); } catch (e) { return 'false'; } return result; } - ///share file to instagram - Future shareToInstagram({required String imagePath}) async { + /// share photo to instagram story + /// [filepath] is local image file path + Future shareToInstagram( + {required String filePath, FileType fileType = FileType.image}) async { final Map arguments = {}; - arguments.putIfAbsent('url', () => imagePath); + arguments.putIfAbsent('url', () => filePath); + if (fileType == FileType.image) { + arguments.putIfAbsent('fileType', () => 'image'); + } else { + arguments.putIfAbsent('fileType', () => 'video'); + } + String? result; + + try { + result = + await _channel.invokeMethod(_methodInstagramShare, arguments); + } catch (e) { + return e.toString(); + } + return result; + } + + /// share text to instagram [Android only] + Future shareToInstagramText({required String msg}) async { + final Map arguments = {}; + arguments.putIfAbsent('msg', () => msg); + String? result; try { - result = await _channel.invokeMethod(_methodInstagramShare, arguments); + result = await _channel.invokeMethod( + _methodInstagramShareText, arguments); } catch (e) { return e.toString(); } diff --git a/pubspec.lock b/pubspec.lock index 9bb813d..45750ef 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,51 +5,50 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.1" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.18.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -64,30 +63,42 @@ packages: dependency: "direct main" description: name: lint - url: "https://pub.dartlang.org" + sha256: "89071bd470cbfcb69c890d94092fc3af947f7c4e3e880f7c82b2988fd348189e" + url: "https://pub.dev" source: hosted - version: "1.7.2" + version: "1.6.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.5.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.10.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.3" sky_engine: dependency: transitive description: flutter @@ -97,58 +108,66 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" source: hosted - version: "0.4.2" - typed_data: + version: "0.6.1" + vector_math: dependency: transitive description: - name: typed_data - url: "https://pub.dartlang.org" + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "1.3.0" - vector_math: + version: "2.1.4" + web: dependency: transitive description: - name: vector_math - url: "https://pub.dartlang.org" + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "0.3.0" sdks: - dart: ">=2.14.0-360.0.dev <3.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=1.12.0"