vincekruger / flutter_whatsapp_stickers

WhatsApp Stickers Plugin for Flutter
https://pub.dev/packages/flutter_whatsapp_stickers
BSD 3-Clause "New" or "Revised" License
38 stars 29 forks source link

Third party pack cannot be found likely because the corresponding app is restricted, sdk: 23 ,power saving mode: false #1

Closed sidoruvigo closed 4 years ago

sidoruvigo commented 4 years ago

I'm having an issue with the example code so I can't add the stickers to whatsapp:

I/flutter ( 9376): _listener
I/flutter ( 9376): StickerPackResult.ERROR
I/flutter ( 9376): true
I/flutter ( 9376): Third party pack cannot be found likely because the corresponding app is restricted, sdk: 23 ,power saving mode: false
sidoruvigo commented 4 years ago

Maybe the JAVA files you have on your root package are missing in the example?

Zeeshan0201 commented 4 years ago

@vincekruger have you find solution for this? getting same error

Third party pack cannot be found likely because the corresponding app is restricted, sdk: 28 ,power saving mode: false

Zeeshan0201 commented 4 years ago

@sidoruvigo can you please elaborate?

vincekruger commented 4 years ago

Awaiting feedback on Whatsapp Channel. This is Whatsapp related. :(

sidoruvigo commented 4 years ago

@Zeeshan0201 @vincekruger

I have tried to replicate this issue from a

Maybe the JAVA files you have on your root package are missing in the example?

I commented this based on flutter_whatsapp_stickers_internet, but they are added inside @vincekruger 's package.

However, with this package I never could add the stickers pack, but the flutter_whatsapp_stickers_internet implementation seems to work just sometimes. When I add a new stickers package with flutter_whatsapp_stickers_internet and then delete it the issue comes and this message can be found on log:

Third party pack cannot be found likely because the corresponding app is restricted, sdk: 23 ,power saving mode: false

For me, this only happens when I change the example stickers pack. If I leave the original example It seems to work until I change it. When the error arises, even if I change back to the original example, It doesn't work again.

I also tried to replicate this issue with this app (I suppose this is an app created with the whatsapp repository. I added and deleted some packages within seconds. After deleting the packages, they don't seem to add again, however, after tapping some times on the Add button, it works again.

As @vincekruger says, this may be a Whatsapp related issue. Hope they will give some feedback.

vincekruger commented 4 years ago

So I've done a lot of debugging on this and the issue seems to come into play when adding multiple packs consecutively. Once the error happens once, the app needs to be restarted. In my production apps, I don't see this error in any of my logs I only come across this when I'm developing. What I've done to mitigate this problem, for now, is to allow 3 - 5 mins before adding another pack to whats app.

I'm keen to wait for Whatsapp to comment on this problem too, my guess is that this is some sort of prevention mechanism they've implemented.

I'll keep this comment open and respond when I have more information.

Zeeshan0201 commented 4 years ago

@vincekruger please let us know when this issue will solve..waiting eagerly...

vincekruger commented 4 years ago

@Zeeshan0201 Whatsapp has marked this as a bug on their side. For now, we have to wait for WhatsApp. :(

I will keep this issue open until it's resolved.

Open Issue on WhatsApp repo: https://github.com/WhatsApp/stickers/issues/584

Zeeshan0201 commented 4 years ago

@vincekruger thanks for the update...

thisisddzin commented 4 years ago

I'm in alert about that, marked your issue on whatsapp/stickers repo and here.. haha You think is an integration problem? I mean Flutter with Whatsapp/stickers android lib?

ctrleffive commented 4 years ago

Hey guys. I think I found a solution to the issue.

What I did was

I found out "image_data_version": "1" property was missing in the JSON file. Let me know if this solved the issue and ill submit a pull request with changes. Thanks.

grayknight2 commented 4 years ago

@ctrleffive This seems to solve the issue for me. I added the stickers pack and deleted it more than 5 times and no error arises.

avoid_cache field was also missing. "image_data_version": "1" was added on this update.

As whatsapp stickers documentation says that are not optinoal fields, so I think this issue is solved...

thisisddzin commented 4 years ago

@vincekruger tell us when update your plugin, thanks.

ctrleffive commented 4 years ago

avoid_cache field was also missing.

@grayknight2 yeh. but without that field also the plugin works. anyway, ill update the documentation and the JSON file an submit a pull request.

vincekruger commented 4 years ago

@ctrleffive Thanks for this.

I've been a little busy with other projects, I will get to this as soon as I have a chance. :)

Push requests are welcome. :)

ahkohd commented 4 years ago

@ctrleffive Thanks for this.

I've been a little busy with other projects, I will get to this as soon as I have a chance. :)

Push requests are welcome. :)

Anticipating.

ahkohd commented 4 years ago

Hey guys. I think I found a solution to the issue.

What I did was

I found out "image_data_version": "1" property was missing in the JSON file. Let me know if this solved the issue and ill submit a pull request with changes. Thanks.

I think it's a partial fix, this only works well if you will add one sticker pack. This does not fix the issue with dynamically generated stickers. You still have to restart the app before WhatsApp can see the second generated sticker pack after adding the first one.

grayknight2 commented 4 years ago

@ahkohd I don't really understand your issue, could you please elaborate?

ahkohd commented 4 years ago

@ahkohd I don't really understand your issue, could you please elaborate?

I am developing a sticker app that you can use to make new stickers and add them to WhatsApp. Therefore at the start of the app, there is no sticker_pack.json file, it's dynamically generated with the other sticker related props, then I use this plugin to send it to Whatsapp. Basically on every export to Whatsapp, you will overwrite the existing sticker props (folders, .json, .webp, .png) with newly generated ones.

The problem is after I generate the first sticker pack and send it to WhatsApp, it works, but it won't work again if you try to export another sticker pack to Whatsapp (Third party pack cannot be found likely because the corresponding app is restricted, sdk: 23 ,power saving mode: false). You have to restart the app.

I have spent days trying to fix this issue but no luck since then. 😓

My observations:

  1. WA detects first generated sticker pack (A) with no problem.
  2. After the first sticker is added to WA, newly generated sticker pack (B - which as 3 stickers) will not be added.
  3. On restart of the app, If I add new stickers to pack (B), let's say I added 2 new stickers to the pack then try to export it to WA, only the previously existing (3) stickers will be added while the later 2 new stickers are ignored.
54lianxi commented 4 years ago

I meet the same problem _listener I/flutter ( 7068): StickerPackResult.ERROR I/flutter ( 7068): true I/flutter ( 7068): Third party pack cannot be found likely because the corresponding app is restricted, sdk: 28 ,power saving mode: false

first,it work ,well, but, only first,It didn't work except for the first time

thisisddzin commented 4 years ago

I meet the same problem _listener I/flutter ( 7068): StickerPackResult.ERROR I/flutter ( 7068): true I/flutter ( 7068): Third party pack cannot be found likely because the corresponding app is restricted, sdk: 28 ,power saving mode: false

first,it work ,well, but, only first,It didn't work except for the first time

Add these fields to each sticker package "avoid_cache": false, "image_data_version": "1" And all will work fine

54lianxi commented 4 years ago

@xdeni I tried as you said, but it didn't work

54lianxi commented 4 years ago
class StickerState extends State<StickerWidget>{

  void initState(){
    for(var i=0;i<widget.iconList.length;i++){
      widget.iconList[i]["checked"] = false;
    }

  }

  String _platformVersion = 'Unknown';

  bool _whatsAppInstalled = false;
  bool _whatsAppConsumerAppInstalled = false;
  bool _whatsAppSmbAppInstalled = false;
  bool _stickerPackInstalled = false;
  String platformVersion;

  WhatsAppStickers _waStickers;

  Future<void> initPlatformState() async {
    _waStickers= WhatsAppStickers();
    try {
      platformVersion = await WhatsAppStickers.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    if (!mounted) return;

    bool whatsAppInstalled = await WhatsAppStickers.isWhatsAppInstalled;
    bool whatsAppConsumerAppInstalled =
    await WhatsAppStickers.isWhatsAppConsumerAppInstalled;
    bool whatsAppSmbAppInstalled =
    await WhatsAppStickers.isWhatsAppSmbAppInstalled;

    _stickerPackInstalled =
    await _waStickers.isStickerPackInstalled(widget.packid);

    setState(() {
      _platformVersion = platformVersion;
      _whatsAppInstalled = whatsAppInstalled;
      _whatsAppConsumerAppInstalled = whatsAppConsumerAppInstalled;
      _whatsAppSmbAppInstalled = whatsAppSmbAppInstalled;
    });
  }
  void dispose(){
    super.dispose();
  }
  Map getJSONFile(){
    List stickers = [];
    for(var i=1;i<widget.iconList.length;i++){
       stickers.add({
         "image_file": widget.iconList[i]["img"],
       });
    }
    Map jsonfile = {
      "android_play_store_link": "",
      "ios_app_store_link": "",
      "sticker_packs":[
        {
          "identifier":widget.packid,
          "name":widget.name,
          "publisher": "Example Sticker Pack",
          "tray_image_file":widget.iconList[0]["img"],
          "publisher_email":"",
          "publisher_website": "",
          "privacy_policy_website": "",
          "license_agreement_website": "",
          "image_data_version":"1",
          "avoid_cache": false,
          "stickers":stickers

        }
      ]
    };
    return jsonfile;
  }

   void  addToWhatsapp () async {
     initPlatformState();
     String dir = (await getApplicationDocumentsDirectory()).path;
     Directory stickersDirectory = Directory("$dir/sticker_packs");
     if (!await stickersDirectory.exists()) {
        await stickersDirectory.create();
     }

     File jsonFile = File('$dir/sticker_packs/sticker_packs.json');
     String content = jsonEncode(getJSONFile());
     jsonFile.writeAsStringSync(content);

     var content2 = await jsonFile.readAsStringSync();
     String url = stickersDirectory.path;
     String packid = widget.packid;
     Directory num = Directory("$url/$packid");
     if(!await num.exists()){
       await num.create();
     }
     String url2 = num.path;
     for(var i=0;i<widget.iconList.length;i++){
       String img = widget.iconList[i]["img"];
       File info =  new File("$dir/$img");
       info.copySync('$url2/$img');
     }

     _waStickers.addStickerPack(
       packageName: WhatsAppPackage.Consumer,
       stickerPackIdentifier: widget.packid,
       stickerPackName: widget.name,
       listener: _listener,
     );

   }

  @override
  Widget build(BuildContext context) {
    return
      Column(
        children: <Widget>[
          Container(
            height:500,
            margin: EdgeInsets.only(top:20),
            child: GridView(
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 4, //横轴三个子widget
                    childAspectRatio: 1//宽高比为1时,子widget
                ),
                children:widget.iconList.map((f){
                  return Column(
                    children: <Widget>[
                    SizedBox(
                      width:60,
                      child: Image(image:
                      NetworkToFileImage(
                          url: iconUrl+f['img'],
                          file: fileFromDocsDir(f["img"]))),
                    )

                    ],
                  );
                }).toList()
            ),
          ),
          Container(
            width:200,
            height:50,
            decoration: BoxDecoration(
                color: Color(0xFFc3185e),
                borderRadius: BorderRadius.all(Radius.circular(25))
            ),
            child: FlatButton(
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(25)
              ),
              color:Color(0xFFc3185e) ,
              child: Text("ADD TO WHATSAPP",
                  style:TextStyle(
                      color: Colors.white
                  )),
              onPressed: () async{
                addToWhatsapp();
              },

            ),
          ),

        ],
      );
    throw UnimplementedError();
  }

  Future<void> _listener(StickerPackResult action, bool result,
      {String error}) async {
    print("_listener");
    print(action);
    print(result);
    print(error);
  }
}
vincekruger commented 4 years ago

I've finally fixed the problem!!! Update coming soon.

ahkohd commented 4 years ago

@vincekruger thanks for the update. Awesome!

tonyCruzNagy commented 2 years ago

hi @ahkohd, I am developing a sticker app that the user download the stickers that it want from my server. it seems that you developed, i think. How did you do? because i have the same problem "Third party pack cannot be found likely because the corresponding app is restricted, sdk: 30 ,power saving mode: false". I tried for 3 days and i don't know the errror

thanks

JulyWitch commented 2 years ago

Same problem here

JulyWitch commented 2 years ago

Same problem here

I fixed it, There were two problems in my code

  1. android_play_store_link and ios_app_store_link had a random URL
  2. I was downloading tray icons but not saving them in the pack directory
roshanbuha commented 1 year ago

Same problem here @tonyCruzNagy

How to fix This Error @thisisddzin
Third party pack cannot be found likely because the corresponding app is restricted, sdk: 33 ,power saving mode: false

Soorajaniyeri commented 1 month ago

same problum please fix it