katzer / cordova-plugin-badge

Access and modify badge numbers
Apache License 2.0
407 stars 254 forks source link

Getting error when build app using Cordova #155

Open aravindforums1 opened 1 year ago

aravindforums1 commented 1 year ago

Hi, i am try to add badge count for android app using cordova-plugin-badge, for that i used ShortcutBadger too. i install cordova-plugin-badge ver 0.8.8 , after i add below code in build.gradle and try to build

repositories {
mavenCentral()
}

 if (!project.ext.has('appShortcutBadgerVersion')) {
 ext.appShortcutBadgerVersion = '1.1.22'
 }

 if (!project.ext.has('appShortcutBadgerCustom')) {
 dependencies {
 //compile "me.leolin:ShortcutBadger:${appShortcutBadgerVersion}@aar"
 implementation "me.leolin:ShortcutBadger:${appShortcutBadgerVersion}@aar"
 }
 }

First i get error for Could not find method compile() for arguments , then i replace compile to implementation still getting error.

Below is the error when build

Note: Before add ShortcutBadger , i can build and install apk file in android phone, that time i added below code in index.js

   if (cordova.plugins.notification.badge.isActivated) {
     alert('cordova-plugin-badge is active');
     console.log('cordova-plugin-badge is active');
     cordova.plugins.notification.badge.set(10);
     } else {
     alert('cordova-plugin-badge is NOT active');
     console.log('cordova-plugin-badge is NOT active');
     cordova.plugins.notification.badge.set(10);
     }

When i run app in mobile device , i always get 'cordova-plugin-badge is NOT active' , not sure how to activate ? I want to show badge count number instead of dot in app icon, currently i get dot in app icon, in mobile setting there is no option to change notification as Number. In whatsapp and sms i can see three options like "Number" , "Dot" and No Badge. Anything need to add in my project config or gradle ?

Thanks and Regards Aravind

ngarafol commented 1 year ago

Hi, You should not use 0.8.8 version of the plugin since it is not fixed yet. You could try using https://github.com/moodlemobile/cordova-plugin-badge/releases/tag/0.8.8-moodle.1 - they have added implementation instead of compile, but for some crazy reason, I still get build errors. Maybe it will work for you :)

Or you could use https://github.com/katzer/cordova-plugin-badge/commit/8e870f7f358d9435180f92dba4d2fc3b7f52bb4f - check comments there.

aravindforums1 commented 1 year ago

Hi, You should not use 0.8.8 version of the plugin since it is not fixed yet. You could try using https://github.com/moodlemobile/cordova-plugin-badge/releases/tag/0.8.8-moodle.1 - they have added implementation instead of compile, but for some crazy reason, I still get build errors. Maybe it will work for you :)

Or you could use 8e870f7 - check comments there.

Hi, i am getting this error when build

D:\Mobile\badge>cordova build android Discovered plugin "cordova-plugin-badge". Adding it to the project Failed to fetch plugin cordova-plugin-badge@^0.8.10 via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. CordovaError: Error: npm: Command failed with exit code 1 Error output: npm ERR! code ETARGET npm ERR! notarget No matching version found for cordova-plugin-badge@^0.8.10. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\bapan\AppData\Local\npm-cache_logs\2023-04-10T04_23_58_200Z-debug-0.log

Regards Aravind

aravindforums1 commented 1 year ago

Hi, You should not use 0.8.8 version of the plugin since it is not fixed yet. You could try using https://github.com/moodlemobile/cordova-plugin-badge/releases/tag/0.8.8-moodle.1 - they have added implementation instead of compile, but for some crazy reason, I still get build errors. Maybe it will work for you :)

Or you could use 8e870f7 - check comments there.

Could you please explain , how to add this plugin in mobile project ? i used this line to add plugin, cordova plugin add @moodlehq/cordova-plugin-badge@0.8.8-moodle.1 but getting error as above

Regards Aravind

ngarafol commented 1 year ago

@aravindforums1 Check your package.json or package-lock.json file. Maybe inside of them there is mentioned cordova-plugin-badge 0.8.10 version. Or if there is no mention in the files, there is a chance some of your plugins have it listed as dependency and it is being installed on its own. This was my case, so I totally removed mention of cordova-plugin-badge from package*.json files since some other plugin uses it as dependency and installs it.