Closed SivaAnishM closed 6 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
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."
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: @.***>
i think there is issue with the library because is not working in background
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); }