Raja0sama / rn-foreground-service

Foreground Service for React Native made with ❤
https://rn-foreground.vercel.app/
148 stars 70 forks source link

Getting error from notificationBuilder.addAction() #86

Closed SivaAnishM closed 6 months ago

SivaAnishM commented 10 months ago

C:\Users\siva_anish\Desktop\foreground RN\AwesomeProject\node_modules\@supersami\rn-foreground-service\android\src\main\java\com\supersami\foregroundservice\NotificationHelper.java:144: error: cannot find symbol notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("buttonText", "Button"), pendingBtnIntent); ^ symbol: variable drawable location: class R C:\Users\siva_anish\Desktop\foreground RN\AwesomeProject\node_modules\@supersami\rn-foreground-service\android\src\main\java\com\supersami\foregroundservice\NotificationHelper.java:148: error: cannot find symbol notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("button2Text", "Button"), pendingBtn2Intent); ^ symbol: variable drawable location: class R Note: C:\Users\siva_anish\Desktop\foreground RN\AwesomeProject\node_modules\@supersami\rn-foreground-service\android\src\main\java\com\supersami\foregroundservice\ForegroundService.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 2 errors

FAILURE: Build failed with an exception.

code //

if(bundle.getBoolean("button", false) == true){ notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("buttonText", "Button"), pendingBtnIntent); }

    if(bundle.getBoolean("button2", false) == true){
        notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("button2Text", "Button"), pendingBtn2Intent);
    }
Sagar-SQT commented 10 months ago

Just add this import in related file, It's a patch. Basic solution for now

Import this

import com.facebook.react.R;

here File C:\Users\siva_anish\Desktop\foreground RN\AwesomeProject\node_modules@supersami\rn-foreground-service\android\src\main\java\com\supersami\foregroundservice\ForegroundService.java

BhavyaCodeAlchemy commented 10 months ago

I got same error in latest react native version 0.73.2

- Solution :

Open the NotificationHelper.java file located at node_modules/@supersami/rn-foreground-service/android/src/main/java/com/supersami/foregroundservice/NotificationHelper.java.

- Locate the following two lines :

notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("buttonText", "Button"), pendingBtnIntent);

notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("button2Text", "Button"), pendingBtn2Intent);

- Replace them with :

notificationBuilder.addAction(com.facebook.react.R.drawable.redbox_top_border_background, bundle.getString("buttonText", "Button"), pendingBtnIntent);

notificationBuilder.addAction(com.facebook.react.R.drawable.redbox_top_border_background, bundle.getString("button2Text", "Button"), pendingBtn2Intent);

- Open package.json and add the following line to the "scripts" section :

"scripts": { "postinstall": "patch-package" // <--- Add }

- Install the patch-package library :

npm i patch-package

- After the installation is complete, run the following command to apply the patch :

npx patch-package @supersami/rn-foreground-service

"This issue has been resolved in my case."

Raja0sama commented 9 months ago

Bravo guys for resolving this issue on your own, raise a PR if you can and i will get this merged, i am extremely busy to support this repo.

You guys rock just to let you know ❤️🔥🔥

Regards, Raja Osama https://rajaosama.me/

On Thu, 1 Feb 2024 at 1:40 PM BhavyaCodeAlchemy @.***> wrote:

I got same error in latest react native version 0.73.2

- Solution :

Open the NotificationHelper.java file located at @.***/rn-foreground-service/android/src/main/java/com/supersami/foregroundservice/NotificationHelper.java.

- Locate the following two lines :

notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("buttonText", "Button"), pendingBtnIntent);

notificationBuilder.addAction(R.drawable.redbox_top_border_background, bundle.getString("button2Text", "Button"), pendingBtn2Intent);

- Replace them with :

notificationBuilder.addAction(com.facebook.react.R.drawable.redbox_top_border_background, bundle.getString("buttonText", "Button"), pendingBtnIntent);

notificationBuilder.addAction(com.facebook.react.R.drawable.redbox_top_border_background, bundle.getString("button2Text", "Button"), pendingBtn2Intent);

- Open package.json and add the following line to the "scripts" section :

"scripts": { "postinstall": "patch-package" // <--- Add }

- Install the patch-package library :

npm i patch-package

- After the installation is complete, run the following command to apply the patch :

npx patch-package @supersami/rn-foreground-service

"This issue has been resolved in my case."

— Reply to this email directly, view it on GitHub https://github.com/Raja0sama/rn-foreground-service/issues/86#issuecomment-1920907971, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDKCRWQQPJMZL7YL3VKMZ3YRNPKHAVCNFSM6AAAAABCRKUTF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRQHEYDOOJXGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

riadhmoussa commented 6 months ago

i think there is issue with the library because is not working in background