1

In my nativescript appllication, I use nativescript-local-notifications NPM to push the local notification and I have followed the instructions same as the readme file in the github.

I face the error

LocalNotifications.schedule: TypeError: builder.setChannelId is not a function

I referred the GitHub issue which is already resolved by someone. But still, I face the issue.

ItemComponent.ts:

   import * as LocalNotifications from "nativescript-local-notifications";
scheduleTesting() {
        console.log("I am inside schedule noti");
        LocalNotifications.hasPermission().then(
            function (granted) {
                console.log("Permission granted -->" + granted);
            }
        )

        LocalNotifications.schedule([{
            id: 0,
            title: 'Sound & Badge',
            body: 'Who needs a push service anyway?',
            badge: 1,
            at: new Date(new Date().getTime() + (5 * 1000)) // 5 seconds from now
          }])


          LocalNotifications.addOnMessageReceivedCallback(data => {
            alert({
              title: "Local Notification received",
              message: `id: '${data.id}', title: '${data.title}'.`,
              okButtonText: "Roger that"
            });
          });

    }

manifestoXML

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="__PACKAGE__"
    android:versionCode="1"
    android:versionName="1.0">

    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"/>

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="__APILEVEL__"/>

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:name="com.tns.NativeScriptApplication"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity
            android:name="com.tns.NativeScriptActivity"
            android:label="@string/title_activity_kimera"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@style/LaunchScreenTheme"
            android:launchMode="singleTop"
            >

            <meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <meta-data android:name="android.app.shortcuts"
                                 android:resource="@xml/shortcuts" />

        </activity>

        <activity 
        android:name="com.tns.ErrorReportActivity"/>
    </application>
</manifest>

API level = 27 "nativescript-local-notifications": "^2.0.3",

GITHub issue url : https://github.com/EddyVerbruggen/nativescript-local-notifications/pull/68

James Z
  • 12,209
  • 10
  • 24
  • 44
Muthukumar Marichamy
  • 1,175
  • 1
  • 17
  • 39

0 Answers0