EddyVerbruggen / nativescript-local-notifications

:mailbox: NativeScript plugin to easily schedule local notifications
MIT License
162 stars 57 forks source link

In Android 4.4 localnotifications undefined #4

Closed jujomago closed 7 years ago

jujomago commented 8 years ago

Notification error:TypeError: Cannot read property 'localnotifications' of undefined

EddyVerbruggen commented 8 years ago

Do you mind sharing more details, or even your project? I've tested this just fine on 4.4 recently.

danazkari commented 8 years ago

Hey @EddyVerbruggen I know you closed this issue but seems like I'm getting the same error and felt wrong to open a new issue :) . I'm using typescript with Angular2 and Android on Ubuntu 14.04 and my project is as vanilla as it can get.

Right now I'm testing a few features to see if it's valid for us in the company to port an application we have to NativeScript. One of the things is local notifications and seems like your lib should work!

Somehow when I try to schedule a notification I get that same error that @jujomago reported in the console.

private sendNotification(title: string, content: string) {
    LocalNotifications.schedule([{
        id: 1,
        title: title,
        body: content,
        ticker: 'The ticker',
        badge: 1,
        sound: null, // suppress sound on Android 
        at: new Date(new Date().getTime() + (10 * 1000)) // 10 seconds from now 
    }]).then(
        function() {
            console.log("Notification scheduled");
        },
        function(error) {
            console.log("scheduling error: " + error);
        }
    );
}

That's how I'm calling the function and this is what the log throws when I call the sendNotification function.

JS: Error in LocalNotifications.schedule: TypeError: Cannot read property 'localnotifications' of undefined
JS: scheduling error: TypeError: Cannot read property 'localnotifications' of undefined

Hope this helps shed some light into the issue. If you need anything else please let me know!

danazkari commented 8 years ago

Did some digging around and seems like for some reason com.telerik is undefined so when it tries to evaluate com.telerik.localnotifications it throws that error. Gonna keep digging but as far as I can tell, the problem is that for some reason the native-code library is not being added. I had this issue before with another plugin and it turned out to be related to the changes with the newest version of NS.

Hope this helps, right now I'm super tight on stuff to do but if by the end of the next 2 weeks you haven't got the time to look into this, I might be able to donate my time.

manuelmarichal commented 7 years ago

Same error here, @EddyVerbruggen.

Exactly the same issue that "danazkari" commented.

I'm using typescript with Angular2

minhquankq commented 7 years ago

The same error, I think we should open new issue instead comment on closed issue.

EddyVerbruggen commented 7 years ago

I'll take a look..

EddyVerbruggen commented 7 years ago

I can only reproduce this by adding the plugin and immediately doing a tns livesync android --watch, but when (at least once) doing tns run android it works fine (you can livesync again afterwards).