GithubHelp home page GithubHelp logo

rohit1814 / flutter_open_whatsapp Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 23.0 69 KB

A Flutter plugin to open WhatsApp and send message to single number.

License: MIT License

Java 26.74% Swift 22.96% Objective-C 4.62% Dart 38.62% Ruby 7.06%

flutter_open_whatsapp's Introduction

Flutter Open WhatsApp

  A Flutter plugin to open WhatsApp and send message to single number in Android and iOS without saving user's number.

Installation

  To use the plugin, add 'flutter_open_whatsapp' as a dependency in your pubspec.yaml file.

Plugin package link

plug-in package

Usage

import 'package:flutter_open_whatsapp/flutter_open_whatsapp.dart';
   
 void main() => runApp(MyApp());
   
    class MyApp extends StatefulWidget {
     @override
     _MyAppState createState() => _MyAppState();
 }
  
 class _MyAppState extends State<MyApp> {

 @override
 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       appBar: AppBar(
         title: const Text('Plugin example app'),
       ),
       body: Center(
         child: MaterialButton(onPressed: (){
           FlutterOpenWhatsapp.sendSingleMessage("918179015345", "Hello");
         },
           child: Text('Running on: $_platformVersion\n'),
         )
       ),
     ),
   );
 }

}

Example

Refer to the example directory of flutter app.

flutter_open_whatsapp's People

Contributors

rohit-kesari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_open_whatsapp's Issues

This plugin is not important!

you can use url_launcher, and device_apps to do everything you need...
i don't use this plugin i faced it randomly, i wanted to help people because it sounds like no body updates this plugin a long time

who want to open WA only, just use this line of code
device_apps:
DeviceApps.openApp('com.whatsapp');

who want to open it with text message use this line of code:
url_launcher:
launch('https://api.whatsapp.com/send/?phone=(phone number here without +)&text=(you message here)&app_absent=1');

does not speficify a SWIFT VERSION

Can't run Pod install. Message below:

[!] Unable to determine Swift version for the following pods:

  • flutter_open_whatsapp does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

flutter open whatsapp does not work with Android 11

Greetings I have an app that has worked perfectly up to android 10, with andoid 11 it does not open whatsApp and it does not show me any error it simply does not do anything, there is something special or some permission that I must give in android 11.

first of all, Thanks

Builds are failing due to forced casts - iOS

Hi, I have been trying to use this package for a Flutter iOS app, but I am getting the following warnings that do not let the app build successfully:

/.pub-cache/hosted/pub.dartlang.org/flutter_open_whatsapp-0.1.2/ios/Classes/SwiftFlutterOpenWhatsappPlugin.swift:30:58: warning: forced cast from 'NSURL?' to 'URL' only unwraps and bridges; did you mean to use '!' with 'as'?
if UIApplication.shared.canOpenURL(whatsAppUrl as! URL) {
~~~~~~~~~~~ ^~~ ~~~
!as

/.pub-cache/hosted/pub.dartlang.org/flutter_open_whatsapp-0.1.2/ios/Classes/SwiftFlutterOpenWhatsappPlugin.swift:31:58: warning: forced cast from 'NSURL?' to 'URL' only unwraps and bridges; did you mean to use '!' with 'as'?
UIApplication.shared.openURL(whatsAppUrl as! URL)
~~~~~~~~~~~ ^~~ ~~~
!as

I am trying to run the app from Android Studio 3.6.3 and building the iOS version with XCode 11.4.1.

What could the problem be? Thanks for your help.

Country code

@rohit1814 when use url_launcher to call a phone number I do something like this:

 final url = "tel:${myInvestment['contact']['phone']}";
                    if (await canLaunch(url)) {
                      await launch(url);
                    } else {
                      throw 'Could not launch $url';
                    }

That would call to the exact phone number I have saved, that means that it would not include extra country codes.

Doing something like this:
FlutterOpenWhatsapp.sendSingleMessage(666666666, "");
will open a +34666666666 and it'd work. But it have +34 on my contact it would add another +34 and it would fail.

Also I cannot have another number from a different country because it adds a wront country code.

I think we should have this logic independently on our sides but not on this package

Crash on iOS

Not working on iOS, it crashes.

OS: Mojave 10.14.6
Xcode: 11.2.1 (11B53)
Flutter: 1.14.4-pre.17 channel master

Tested on iPhone X

iOS crash

Environment

Dependencies

  • dart: 2.8.4
  • flutter: 1.17.5
  • flutter_open_whastapp: 0.1.2

Device:

Device
Model: iPhone 8
Orientation: Portrait
RAM free: 34.61 MB
Disk free: 50.62 GB
Operating System
Version: 13.5.1 (17F80)
Orientation: Portrait
Jailbroken: No

What is happening

I use this library like this:

    final message ="Hola, me gustó!";
    final number = "+5715188076";
    FlutterOpenWhatsapp.sendSingleMessage(number, message);

I dont get where is the issue, the error is criptic :P.
Im getting no issues on android, but for iOS it crashes and prints this error:

Crashed: com.apple.main-thread
0  flutter_open_whatsapp          0x102cb341c $s21flutter_open_whatsapp30SwiftFlutterOpenWhatsappPluginC6handle_6resultySo0E10MethodCallC_yypSgctFyycfU_ + 1776
1  flutter_open_whatsapp          0x102cb362c $sIeg_IeyB_TR + 28
2  libdispatch.dylib              0x1a673a9a8 _dispatch_call_block_and_release + 24
3  libdispatch.dylib              0x1a673b524 _dispatch_client_callout + 16
4  libdispatch.dylib              0x1a671e6fc _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 860
5  CoreFoundation                 0x1a69f37fc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
6  CoreFoundation                 0x1a69ee6d0 __CFRunLoopRun + 1724
7  CoreFoundation                 0x1a69edce8 CFRunLoopRunSpecific + 424
8  GraphicsServices               0x1b0b3838c GSEventRunModal + 160
9  UIKitCore                      0x1aab1c444 UIApplicationMain + 1932
10 Runner                         0x1023672ac main + 6 (AppDelegate.swift:6)
11 libdyld.dylib                  0x1a68758f0 start + 4

Bug: Complete message not being sent.

Test message: Hello # World
Message shown in whatsapp: Hello

I found the error was because the plugin was not encoding the message in URI format, due to this it escaped at "#". It is a critical bug and I think the library should encode the message and then send it.

Would be happy to contribute :)

Can you also send images?

I would like to be able to send images to people who are not in my contact list. Would that be possible with this plugin?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.