3

I'll be using react-native-push-notification for notifications in my app but when I use this library it gives me error like this.....

> Task :react-native-push-notification:compileDebugJavaWithJavac FAILED
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:7: error: cannot find symbol
import android.app.NotificationChannel;
                  ^
  symbol:   class NotificationChannel
  location: package android.app
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:480: error: cannot find symbol
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
                                                       ^
  symbol:   variable O
  location: class VERSION_CODES
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:488: error: cannot find symbol
        int importance = NotificationManager.IMPORTANCE_DEFAULT;
                                            ^
  symbol:   variable IMPORTANCE_DEFAULT
  location: class NotificationManager
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:489: error: cannot find symbol
        NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
        ^
  symbol:   class NotificationChannel
  location: class RNPushNotificationHelper
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:489: error: cannot find symbol
        NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
                                          ^
  symbol:   class NotificationChannel
  location: class RNPushNotificationHelper
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
Paradowski
  • 719
  • 1
  • 13
  • 17
Akshay I
  • 3,675
  • 1
  • 34
  • 57

3 Answers3

6

Try to upgrade on react-native-push-notification/android/build.gradle this dependencies

  • def DEFAULT_COMPILE_SDK_VERSION = 26
  • def DEFAULT_BUILD_TOOLS_VERSION = "26.1.0"
  • def DEFAULT_TARGET_SDK_VERSION = 23
  • def DEFAULT_SUPPORT_LIB_VERSION = "26.1.0"
  • def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+"
  • def DEFAULT_FIREBASE_MESSAGING_VERSION = "+"

let me know if that helps you

Error whith RNPushNotifications android

Helmer Barcos
  • 1,898
  • 12
  • 18
  • Thanks It's working but, can please tell me how I can Implement FCM Notification, I'm already config all the setup but It's not working. I'm send the notification Throughout the FCM Application will crash. please provide me solution for this issue... – Akshay I Aug 04 '18 at 05:21
  • which FCM service do you use? – Helmer Barcos Aug 04 '18 at 05:32
  • I'm not experienced in react-native so please can guide which service is best & how to implement that... – Akshay I Aug 04 '18 at 05:35
  • okey it is a bit complicated. first of all im not sure if you want to pay for these micoreservices. U use Firebase for back-end and for sending notifications to my users it is for free for small apps and it would be better if you use [React-Native-Firebase](https://rnfirebase.io/). It seems to me the easiest way to configure a service for PushNotifications. in that web you find the documentation for all you need to configurate in your project. let me know if you need support. – Helmer Barcos Aug 04 '18 at 05:47
  • Thanks...@Helmer Barcos – Akshay I Aug 04 '18 at 05:49
1

I've had this problem also, after fixing the deprecated 'compile' issue in the dependency configurations - module's build.gradle, however, I didn't change the SDK versions there, instead I've added API Level 28 on SDK Platforms in Android Studio and ... voilà.

gesf
  • 63
  • 7
0

Increase the complieSDK >= 26 (Oreo). Notification channel was introduced in Oreo or SDK 26