GithubHelp home page GithubHelp logo

applicazza / whatsapp_stickers Goto Github PK

View Code? Open in Web Editor NEW
17.0 4.0 34.0 508 KB

A Flutter plugin for adding stickers to WhatsApp.

License: MIT License

Ruby 3.43% Swift 29.97% Objective-C 0.80% Dart 7.96% Kotlin 6.72% Java 51.12%
whatsapp stickers flutter

whatsapp_stickers's Introduction

whatsapp_stickers

A Flutter plugin for adding stickers to WhatsApp.

Notes

  • trayImageFileName uses PNG data whereas stickers use WebP data.

Usage

To use this plugin, add whatsapp_stickers as a dependency in your pubspec.yaml file.

Android

Add the following option to your app\build.gradle file. This will prevent all WebP files from being compressed.

android {
    aaptOptions {
        noCompress "webp"
    }
}

iOS

Do not forget to add following entry to Info.plist with Runner target.

<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>whatsapp</string>
	</array>

Examples

Local assets

Put your stickers in any folder, for example, assets. Do not forget to add this folder to pubspec.yaml.

const stickers = {
  '01_Cuppy_smile.webp': ['โ˜•', '๐Ÿ™‚'],
  '02_Cuppy_lol.webp': ['๐Ÿ˜„', '๐Ÿ˜€'],
  '03_Cuppy_rofl.webp': ['๐Ÿ˜†', '๐Ÿ˜‚'],
  '04_Cuppy_sad.webp': ['๐Ÿ˜ƒ', '๐Ÿ˜'],
  '05_Cuppy_cry.webp': ['๐Ÿ˜ญ', '๐Ÿ’ง'],
  '06_Cuppy_love.webp': ['๐Ÿ˜', 'โ™ฅ'],
  '07_Cuppy_hate.webp': ['๐Ÿ’”', '๐Ÿ‘Ž'],
  '08_Cuppy_lovewithmug.webp': ['๐Ÿ˜', '๐Ÿ’‘'],
  '09_Cuppy_lovewithcookie.webp': ['๐Ÿ˜˜', '๐Ÿช'],
  '10_Cuppy_hmm.webp': ['๐Ÿค”', '๐Ÿ˜'],
  '11_Cuppy_upset.webp': ['๐Ÿ˜ฑ', '๐Ÿ˜ต'],
  '12_Cuppy_angry.webp': ['๐Ÿ˜ก', '๐Ÿ˜ '],
  '13_Cuppy_curious.webp': ['โ“', '๐Ÿค”'],
  '14_Cuppy_weird.webp': ['๐ŸŒˆ', '๐Ÿ˜œ'],
  '15_Cuppy_bluescreen.webp': ['๐Ÿ’ป', '๐Ÿ˜ฉ'],
  '16_Cuppy_angry.webp': ['๐Ÿ˜ก', '๐Ÿ˜ค'],
  '17_Cuppy_tired.webp': ['๐Ÿ˜ฉ', '๐Ÿ˜จ'],
  '18_Cuppy_workhard.webp': ['๐Ÿ˜”', '๐Ÿ˜จ'],
  '19_Cuppy_shine.webp': ['๐ŸŽ‰', 'โœจ'],
  '20_Cuppy_disgusting.webp': ['๐Ÿคฎ', '๐Ÿ‘Ž'],
  '21_Cuppy_hi.webp': ['๐Ÿ–', '๐Ÿ™‹'],
  '22_Cuppy_bye.webp': ['๐Ÿ–', '๐Ÿ‘‹'],
};

Future installFromAssets() async {
  var stickerPack = WhatsappStickers(
    identifier: 'cuppyFlutterWhatsAppStickers',
    name: 'Cuppy Flutter WhatsApp Stickers',
    publisher: 'John Doe',
    trayImageFileName: WhatsappStickerImage.fromAsset('assets/tray_Cuppy.png'),
    publisherWebsite: '',
    privacyPolicyWebsite: '',
    licenseAgreementWebsite: '',
  );

  stickers.forEach((sticker, emojis) {
    stickerPack.addSticker(WhatsappStickerImage.fromAsset('assets/$sticker'), emojis);
  });

  try {
    await stickerPack.sendToWhatsApp();
  } on WhatsappStickersException catch (e) {
    print(e.cause);
  }
}

Remote assets

const stickers = {
  '01_Cuppy_smile.webp': ['โ˜•', '๐Ÿ™‚'],
  '02_Cuppy_lol.webp': ['๐Ÿ˜„', '๐Ÿ˜€'],
  '03_Cuppy_rofl.webp': ['๐Ÿ˜†', '๐Ÿ˜‚'],
  '04_Cuppy_sad.webp': ['๐Ÿ˜ƒ', '๐Ÿ˜'],
  '05_Cuppy_cry.webp': ['๐Ÿ˜ญ', '๐Ÿ’ง'],
  '06_Cuppy_love.webp': ['๐Ÿ˜', 'โ™ฅ'],
  '07_Cuppy_hate.webp': ['๐Ÿ’”', '๐Ÿ‘Ž'],
  '08_Cuppy_lovewithmug.webp': ['๐Ÿ˜', '๐Ÿ’‘'],
  '09_Cuppy_lovewithcookie.webp': ['๐Ÿ˜˜', '๐Ÿช'],
  '10_Cuppy_hmm.webp': ['๐Ÿค”', '๐Ÿ˜'],
  '11_Cuppy_upset.webp': ['๐Ÿ˜ฑ', '๐Ÿ˜ต'],
  '12_Cuppy_angry.webp': ['๐Ÿ˜ก', '๐Ÿ˜ '],
  '13_Cuppy_curious.webp': ['โ“', '๐Ÿค”'],
  '14_Cuppy_weird.webp': ['๐ŸŒˆ', '๐Ÿ˜œ'],
  '15_Cuppy_bluescreen.webp': ['๐Ÿ’ป', '๐Ÿ˜ฉ'],
  '16_Cuppy_angry.webp': ['๐Ÿ˜ก', '๐Ÿ˜ค'],
  '17_Cuppy_tired.webp': ['๐Ÿ˜ฉ', '๐Ÿ˜จ'],
  '18_Cuppy_workhard.webp': ['๐Ÿ˜”', '๐Ÿ˜จ'],
  '19_Cuppy_shine.webp': ['๐ŸŽ‰', 'โœจ'],
  '20_Cuppy_disgusting.webp': ['๐Ÿคฎ', '๐Ÿ‘Ž'],
  '21_Cuppy_hi.webp': ['๐Ÿ–', '๐Ÿ™‹'],
  '22_Cuppy_bye.webp': ['๐Ÿ–', '๐Ÿ‘‹'],
};

Future installFromRemote() async {
  var applicationDocumentsDirectory = await getApplicationDocumentsDirectory();
  var stickersDirectory = Directory('${applicationDocumentsDirectory.path}/stickers');
  await stickersDirectory.create(recursive: true);

  final dio = Dio();
  final downloads = <Future>[];

  stickers.forEach((sticker, emojis) {
    downloads.add(
      dio.download(
        'https://github.com/applicazza/whatsapp_stickers/raw/master/example/assets/$sticker',
        '${stickersDirectory.path}/$sticker',
      ),
    );
  });

  await Future.wait(downloads);

  var stickerPack = WhatsappStickers(
    identifier: 'cuppyFlutterWhatsAppStickers',
    name: 'Cuppy Flutter WhatsApp Stickers',
    publisher: 'John Doe',
    trayImageFileName: WhatsappStickerImage.fromAsset('assets/tray_Cuppy.png'),
    publisherWebsite: '',
    privacyPolicyWebsite: '',
    licenseAgreementWebsite: '',
  );

  stickers.forEach((sticker, emojis) {
    stickerPack.addSticker(WhatsappStickerImage.fromFile('${stickersDirectory.path}/$sticker'), emojis);
  });

  try {
    await stickerPack.sendToWhatsApp();
  } on WhatsappStickersException catch (e) {
    print(e.cause);
  }
}

whatsapp_stickers's People

Contributors

applicazza avatar artyoms-yad2 avatar elihaidv avatar mzohaibnaaz avatar timekone avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

whatsapp_stickers's Issues

App Crashing after using some time

App crashing after installing the app on android mobile.
And I'm unable to add stickers to whatsapp even in debug mode. It is raising an Java IO Exception : Can't load the file although all files are included correctly.

The "WhatsApp is not installed" exception doesn't throw on iOS

On Android, when WhatsApp is not installed, the WhatsappStickers.sendToWhatsApp() method throws WhatsappStickersException with WhatsappStickersException.cause "WhatsApp is not installed on target device!".
This makes it fairly easy to show a dialog to users prompting them to install WhatsApp.

Unfortunately, on iOS, no exception is thrown.
Instead, the following message appears 3 times in the console:
-canOpenURL: failed for URL: "whatsapp://" - error: "The operation couldnโ€™t be completed. (OSStatus error -10814.)"

It would be great if iOS had the same behavior as Android.

whatsapp_stickers: 0.0.4
iOS: 14.4

For those looking for a fix, I created a new package

First, thank you @applicazza for POC and code base.

However, this package is broken and seems no longer being maintained.

I create a new package here: https://pub.dev/packages/whatsapp_stickers_exporter , which is freshly drafted and tested on both iOS and Android and confirmed working, some codes are borrowed from this project.

The one I made also supports animated stickers on both platforms, and addressed the sticker order issue.

Repo is here: https://github.com/star-39/whatsapp_stickers_exporter

How can i verify weather a sticker is already added to whats app or not?

We are sending the Sticker pack to what's app but how can i verify weather a particular sticker is already added or not to whats app...

I would like to show a plus icon if its not added and if it is already added then i would like to show a check mark...
Can any one tell the necessary stuff to do for the verification of this thing..

Keep trying add to whatsapp

Hi. Thanks about this library. It helps a lot.
Version 0.0.4 is much better. But still one bug:

Steps:

  1. Add package to WA
  2. Exit form WA. Doesn't matter if package added or not.
  3. Back to my app
  4. My app trying to add the package again and again
  5. Sometimes after that, WA crashing, or error message: "operation couldn't be completed(com.third-party-sticker 1000)"

My code:

  var stickerPack = WhatsappStickers(
        identifier: category.identifier,
        name: category.title,
        publisher: pack.publisher,
        trayImageFileName: WhatsappStickerImage.fromFile(
            '${category.directoryPath}/${category.trayImageFile}'),
        publisherWebsite: pack.publisherWebsite,
        privacyPolicyWebsite: pack.privacyPolicyWebsite,
        licenseAgreementWebsite: pack.licenseAgreementWebsite,
      );

      category.stickers.forEach((sticker) {
        stickerPack.addSticker(
            WhatsappStickerImage.fromFile(
                '${category.directoryPath}/${sticker.imageFile}'),
            sticker.emojis);
      });

      stickerPack
          .sendToWhatsApp()
          .then((value) => analytics.logEvent(name: 'SuccessfullyAddedPackage'))
          .catchError((err) {
        print(err);
        analytics.logEvent(name: 'FailedAddedPackage');
      });

Link for video of the problem:

I need your help about stickers, Whatsapp and Xcode

I do like to learn how to add my own stickers for Whatsapp from Xcode. If you can make print screens or tutorial video for me. It is easy for me to understand better tutorial video or print screens.

I would be appreciate.

Missing Plugin Exception

Whenever I launch the app on my android phone an try to add the stickers pack I run into Missing Plugin Exception error.I googled for the reason and tried flutter clean command but the issue still occurred

Annotation 2019-12-20 180902

Please upgrade the package

The package is outdated and not compatible with flutter SDK 3.0, even conflicts with the package (video_editor 1.4.3)

"There's a problem with this sticker pack and it cant be added to Whatsapp" on android for remote assets

On android when trayImageFileName is used from remote and identifier is not "cuppyFlutterWhatsAppStickers" gives this error from whatsapp

working code

  var stickerPack = WhatsappStickers(
    name: 'Vinil test',
    publisher: 'Vinil Prabhu',
    identifier: 'cuppyFlutterWhatsAppStickers',
    trayImageFileName: WhatsappStickerImage.fromFile(
        '${stickersDirectory.path}/tray_Cuppy.png'),
    publisherWebsite: '',
    privacyPolicyWebsite: '',
    licenseAgreementWebsite: '',
  );

this throws error

  var stickerPack = WhatsappStickers(
  name: 'Vinil test',
  publisher: 'Vinil Prabhu',
  identifier: 'viniltestOne',
  trayImageFileName: WhatsappStickerImage.fromFile(
      '${stickersDirectory.path}/tray_Cuppy.png'),
  publisherWebsite: '',
  privacyPolicyWebsite: '',
  licenseAgreementWebsite: '',
);

whatsapp_stickers: 0.0.4
android: 11
whatsapp: 2.21.15.15

Always get FILE_NOT_FOUND Exception

my sticker are stored in server so first user download stickers and i store those sticker into Application Documents Directory with help of getApplicationDocumentsDirectory() method and after that i call the " await stickerPack.sendToWhatsApp();" but always get FILE_NOT_FOUND Exception.

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.