Git Product home page Git Product logo

nativescript-local-notifications's Introduction

NativeScript Local Notifications Plugin

NPM version Downloads Twitter Follow

The Local Notifications plugin allows your app to show notifications when the app is not running. Just like remote push notifications, but a few orders of magnitude easier to set up.

⚠️ Plugin version 4.0.0 should be used with NativeScript 6+. If you have an older tns --version, please use an older plugin version.

⚠️ Looking for NativeScript 7 compatibilty? Go to the NativeScript/plugins repo.

Installation

From the command prompt go to your app's root folder and execute:

tns plugin add nativescript-local-notifications

Setup (since plugin version 3.0.0)

Add this so for iOS 10+ we can do some wiring (set the iOS UNUserNotificationCenter.delegate, to be precise). Not needed if your app loads the plugin on startup anyway.

You'll know you need this if on iOS 10+ notifications are not received by your app or addOnMessageReceivedCallback is not invoked... better safe than sorry, though!

require ("nativescript-local-notifications");

Now you can import the plugin as an object into your .ts file as follows:

// either
import { LocalNotifications } from "nativescript-local-notifications";
// or (if that doesn't work for you)
import * as LocalNotifications from "nativescript-local-notifications";

// then use it as:
LocalNotifications.hasPermission()

Demo apps

NativeScript-Core (XML)

This demo is the one with the most options, so it's a cool one to check out:

git clone https://github.com/EddyVerbruggen/nativescript-local-notifications
cd nativescript-local-notifications/src
npm run demo.ios # or demo.android

NativeScript-Angular

This plugin is part of the plugin showcase app I built using Angular.

There's also a simple Angular demo in this repo:

git clone https://github.com/EddyVerbruggen/nativescript-local-notifications
cd nativescript-local-notifications/src
npm run demo-ng.ios # or demo-ng.android

NativeScript-Vue

We also have a Vue demo:

git clone https://github.com/EddyVerbruggen/nativescript-local-notifications
cd nativescript-local-notifications/src
npm run demo-vue.ios # or demo-vue.android

Plugin API

schedule

On iOS you need to ask permission to schedule a notification. You can have the schedule funtion do that for you automatically (the notification will be scheduled in case the user granted permission), or you can manually invoke requestPermission if that's your thing.

You can pass several options to this function, everything is optional:

option description
id A number so you can easily distinguish your notifications. Will be generated if not set.
title The title which is shown in the statusbar. Default not set.
subtitle Shown below the title on iOS, and next to the App name on Android. Default not set. All android and iOS >= 10 only.
body The text below the title. If not provided, the subtitle or title (in this order or priority) will be swapped for it on iOS, as iOS won't display notifications without a body. Default not set on Android, ' ' on iOS, as otherwise the notification won't show up at all.
color Custom color for the notification icon and title that will be applied when the notification center is expanded. (Android Only)
bigTextStyle Allow more than 1 line of the body text to show in the notification centre. Mutually exclusive with image. Default false. (Android Only)
groupedMessages An array of atmost 5 messages that would be displayed using android's notification inboxStyle. Note: The array would be trimed from the top if the messages exceed five. Default not set
groupSummary An inboxStyle notification summary. Default empty
ticker On Android you can show a different text in the statusbar, instead of the body. Default not set, so body is used.
at A JavaScript Date object indicating when the notification should be shown. Default not set (the notification will be shown immediately).
badge On iOS (and some Android devices) you see a number on top of the app icon. On most Android devices you'll see this number in the notification center. Default not set (0).
sound Notification sound. For custom notification sound (iOS only), copy the file to App_Resources/iOS. Set this to "default" (or do not set at all) in order to use default OS sound. Set this to null to suppress sound.
interval Set to one of second, minute, hour, day, week, month, year if you want a recurring notification.
icon On Android you can set a custom icon in the system tray. Pass in res://filename (without the extension) which lives in App_Resouces/Android/drawable folders. If not passed, we'll look there for a file named ic_stat_notify.png. By default the app icon is used. Android < Lollipop (21) only (see silhouetteIcon below).
silhouetteIcon Same as icon, but for Android >= Lollipop (21). Should be an alpha-only image. Defaults to res://ic_stat_notify_silhouette, or the app icon if not present.
image URL (http..) of the image to use as an expandable notification image. On Android this is mutually exclusive with bigTextStyle.
thumbnail Custom thumbnail/icon to show in the notification center (to the right) on Android, this can be either: true (if you want to use the image as the thumbnail), a resource URL (that lives in the App_Resouces/Android/drawable folders, e.g.: res://filename), or a http URL from anywhere on the web. (Android Only). Default not set.
ongoing Default is (false). Set whether this is an ongoing notification. Ongoing notifications cannot be dismissed by the user, so your application must take care of canceling them. (Android Only)
channel Default is (Channel). Set the channel name for Android API >= 26, which is shown when the user longpresses a notification. (Android Only)
forceShowWhenInForeground Default is false. Set to true to always show the notification. Note that on iOS < 10 this is ignored (the notification is not shown), and on newer Androids it's currently ignored as well (the notification always shows, per platform default).
priority Default is 0. Will override forceShowWhenInForeground if set. This can be set to 2 for Android "heads-up" notifications. See #114 for details.
actions Add an array of NotificationAction objects (see below) to add buttons or text input to a notification.
notificationLed Enable the notification LED light on Android (if supported by the device), this can be either: true (if you want to use the default color), or a custom color for the notification LED light (if supported by the device). (Android Only). Default not set.

NotificationAction

option description
id An id so you can easily distinguish your actions.
type Either button or input.
title The label for type = button.
launch Launch the app when the action completes.
submitLabel The submit button label for type = input.
placeholder The placeholder text for type = input.
  LocalNotifications.schedule([{
    id: 1, // generated id if not set
    title: 'The title',
    body: 'Recurs every minute until cancelled',
    ticker: 'The ticker',
    color: new Color("red"),
    badge: 1,
    groupedMessages:["The first", "Second", "Keep going", "one more..", "OK Stop"], //android only
    groupSummary:"Summary of the grouped messages above", //android only
    ongoing: true, // makes the notification ongoing (Android only)
    icon: 'res://heart',
    image: "https://cdn-images-1.medium.com/max/1200/1*c3cQvYJrVezv_Az0CoDcbA.jpeg",
    thumbnail: true,
    interval: 'minute',
    channel: 'My Channel', // default: 'Channel'
    sound: "customsound-ios.wav", // falls back to the default sound on Android
    at: new Date(new Date().getTime() + (10 * 1000)) // 10 seconds from now
  }]).then(
      function(scheduledIds) {
        console.log("Notification id(s) scheduled: " + JSON.stringify(scheduledIds));
      },
      function(error) {
        console.log("scheduling error: " + error);
      }
  )

Notification icons (Android)

These options default to res://ic_stat_notify and res://ic_stat_notify_silhouette respectively, or the app icon if not present.

silhouetteIcon should be an alpha-only image and will be used in Android >= Lollipop (21).

These are the official icon size guidelines, and here's a great guide on how to easily create these icons on Android.

Density qualifier px dpi
ldpi 18 × 18 120
mdpi 24 × 24 160
hdpi 36 × 36 240
xhdpi 48 × 48 320
xxhdpi 72 × 72 480
xxxhdpi 96 × 96 640 approx.

Source: Density Qualifier Docs

addOnMessageReceivedCallback

Tapping a notification in the notification center will launch your app. But what if you scheduled two notifications and you want to know which one the user tapped?

Use this function to have a callback invoked when a notification was used to launch your app. Note that on iOS it will even be triggered when your app is in the foreground and a notification is received.

  LocalNotifications.addOnMessageReceivedCallback(
      function (notification) {
        console.log("ID: " + notification.id);
        console.log("Title: " + notification.title);
        console.log("Body: " + notification.body);
      }
  ).then(
      function() {
        console.log("Listener added");
      }
  )

getScheduledIds

If you want to know the ID's of all notifications which have been scheduled, do this:

Note that all functions have an error handler as well (see schedule), but to keep things readable we won't repeat ourselves.

  LocalNotifications.getScheduledIds().then(
      function(ids) {
        console.log("ID's: " + ids);
      }
  )

cancel

If you want to cancel a previously scheduled notification (and you know its ID), you can cancel it:

  LocalNotifications.cancel(5 /* the ID */).then(
      function(foundAndCanceled) {
          if (foundAndCanceled) {
            console.log("OK, it's gone!");
          } else {
            console.log("No ID 5 was scheduled");
          }
      }
  )

cancelAll

If you just want to cancel all previously scheduled notifications, do this:

  LocalNotifications.cancelAll();

requestPermission

On Android you don't need permission, but on iOS you do. Android will simply return true.

If the requestPermission or schedule function previously ran the user has already been prompted to grant permission. If the user granted permission this function returns true, but if he denied permission this function will return false, since an iOS can only request permission once. In which case the user needs to go to the iOS settings app and manually enable permissions for your app.

  LocalNotifications.requestPermission().then(
      function(granted) {
        console.log("Permission granted? " + granted);
      }
  )

hasPermission

On Android you don't need permission, but on iOS you do. Android will simply return true.

If the requestPermission or schedule functions previously ran you may want to check whether or not the user granted permission:

  LocalNotifications.hasPermission().then(
      function(granted) {
        console.log("Permission granted? " + granted);
      }
  )

nativescript-local-notifications's People

Contributors

alg avatar dannyfeliz avatar danziger avatar dependabot[bot] avatar eddyverbruggen avatar edusperoni avatar enesasillioglu avatar etabakov avatar ezlo-ionutrusu avatar htbkoo avatar ickata avatar nikolayczyk avatar oleklapp avatar oncul avatar patricklx avatar robophil avatar saeb-panahifar avatar samuelagm avatar surdu avatar triniwiz avatar vladwelt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-local-notifications's Issues

ReferenceError: Can't find variable: Notification

I'm getting this error. I tried ading and removing ios platform and , using tns run but still getting same error. any Ideas?

    "tns-ios": {
      "version": "2.5.0"
    }



  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/router": "3.2.1",
    "clone": "2.0.0",
    "email-validator": "1.0.7",
    "moment": "2.15.2",
    "nativescript-angular": "1.1.3",
    "nativescript-appavailability": "^1.2.0",
    "nativescript-appversion": "1.3.2",
    "nativescript-clipboard": "1.1.5",
    "nativescript-directions": "1.0.2",
    "nativescript-fancyalert": "^1.1.2",
    "nativescript-iqkeyboardmanager": "1.0.1",
    "nativescript-local-notifications": "1.1.8",
    "nativescript-phone": "1.2.3",
    "nativescript-pulltorefresh": "1.1.8",
    "nativescript-timedatepicker": "1.0.0",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.0-beta.12",
    "tns-core-modules": "^2.5.0-2016-12-07-4948"
  },
  "devDependencies": {
    "babel-traverse": "6.9.0",
    "babel-types": "6.10.0",
    "babylon": "6.8.1",
    "filewalker": "0.1.2",
    "gulp": "^3.9.1",
    "gulp-clean": "^0.3.2",
    "gulp-replace": "^0.5.4",
    "lazy": "1.0.11",
    "nativescript-dev-sass": "^0.1.0",
    "nativescript-dev-typescript": "^0.3.2",
    "typescript": "2.0.10",
    "zone.js": "^0.6.21"
  }

Project successfully built
Successfully deployed on device with identifier 'C3EF9E34-AAD3-40AD-B15F-1D1382B079AC'.
1   0x1068ce33c -[TNSRuntime executeModule:referredBy:]
2   0x106421549 main
Feb  1 08:58:41 HEILAP66 nativehealthsignal[49216]: 3   0x10aae792d start
Feb  1 08:58:41 HEILAP66 nativehealthsignal[49216]: 4   0x1
file:///app/tns_modules/nativescript-local-notifications/local-notifications.js:26:37: JS ERROR ReferenceError: Can't find variable: Notification
Feb  1 08:58:41 com.apple.CoreSimulator.SimDevice.C3EF9E34-AAD3-40AD-B15F-1D1382B079AC.launchd_sim[48795] (UIKitApplication[0xc932][49216]): Service exited due to signal: Segmentation fault: 11


Not compiling in {N} 1.7.1

I am having a hard time trying to compile.. it is always throwing errors...

:mergeNativescript-geolocationNativescript-local-notificationsNativescript-plugin-google-play-servicesNativescript-push-notificationsDebugResources FAILED

No sound, no notification, only listed in notifications

Hi, I was trying to implement your plugin to my android nativescript app but notification message or sound didnt show up after calling notification. Notification was only listed in other notifications list and app icon was showing red dot. I thought the problem was in my app, but after downloading your demo app repository, the issues were same on every type of notification in demo app. No message showing, no sound played, only displayed in notification list. I tried also older versions of plugin in your demo app, there the default sound notification started to work, but still no message showing in the top of the screen. I am testing it on Android 6.0.1 phone. Do you have any clue what could be the problem?

Incorrect package.json and d.ts to use as node module.

First. Thanks for this fantastic plugin.

I had problems to use it as node module when you install wirh npm install.

To solve it:

Open node_modules/nativescript-local-notifications/local-package.json and add
"typings": "local-notifications.d.ts" as new object property.

Later, go to local-notifications.d.ts and remove declare module "nativescript-local-notifications" {}
Remove module declaration, not members inside it.

Now you can use it wrtiting, for example:

import {schedule} from "nativescript-local-notifications"

without import d.ts as reference

module not found

I am trying to use this plugin with NativeScript 2 and typescript but I got error telling that the module is not found

Update notification title/body

As far as I can tell, there is no way to retrieve a notification after it is scheduled in order to update it.

A scenario where one would want to do that is for ongoing notifications like "Downloading... 20%"

Error and build exception on Nativescript 1.7

Build failed with an exception

:cleanLocalAarFiles
:ensureMetadataOutDir
:collectAllJars
:buildMetadata
Exception in thread "main" java.lang.IllegalArgumentException: Class com.google.android.gms.ads.formats.NativeAd$Image conflict: /Users/macbook/apptest/platforms/android/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/7.5.0/jars/classes.jar and /Users/macbook/apptest/node_modules/nativescript-local-notifications/node_modules/nativescript-plugin-google-play-services/platforms/android/google-play-services_lib/libs/google-play-services.jar
    at com.telerik.metadata.ClassRepo.cacheJarFile(ClassRepo.java:21)
    at com.telerik.metadata.Builder.build(Builder.java:38)
    at com.telerik.metadata.Generator.main(Generator.java:44)
:buildMetadata FAILED

* What went wrong:
Execution failed for task ':buildMetadata'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

Using:
Nativescript 1.7.1
Android 5.1

Extra modules:
nativescript-admob
lodash

TypeError: utils.ios.getter is not a function

I'm trying to use this plugin but something seems wrong. When I'm running directly in my iPhone it generate an error:

JS ERROR Error: Could not find module 'nativescript-local-notifications'. Computed path '/var/mobile/Containers/Data/Application/C9B5D50C-78BB-4CB3-BB0B-ABBF226F3D26/Library/Application Support/LiveSync/app/tns_modules/nativescript-local-notifications'.

Once I've tried run it in iOS simulator another exception is raised:


file:///app/tns_modules/nativescript-local-notifications/local-notifications.js:5:36: JS ERROR TypeError: utils.ios.getter is not a function. (In 'utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter)', 'utils.ios.getter' is undefined)
Oct 17 01:04:19 Marcios-MacBook-Pro-2 com.apple.CoreSimulator.SimDevice.62A75B7E-B30D-449A-B77E-F7DE858C4547.launchd_sim[7398] (UIKitApplication:org.nativescript.smartdietTS[0xcd70][61786]): Service exited due to signal: Segmentation fault: 11

Anyone have an idea about this?

Notification.new is not a function

I have updated to nativescript to 2.3 and the newest xcode. I then updated this plugin, but now Im getting the following error when trying to use it:

file:///app/tns_modules/nativescript-local-notifications/local-notifications.js:26:41: JS ERROR TypeError: Notification.new is not a function. (In 'Notification.new()', 'Notification.new' is undefined)

Click in Notification don't call onActivityCreated (android)

Everything works fine. Thanks for this plugin.

But, I am facing a problem.
When the app is closed and the user touch the notification the app opens, but the function onActivityCreated is not called.
application.android.onActivityCreated = function(activity) {...}
Another functions like onActivityStarted are called normally.

Is this an error? Is this the default behaviour? Can I be doing something wrong?

ios simulator throws local-notifications.js:26:37: JS ERROR ReferenceError: Can't find variable: Notification

Hi There,

When running with the ios simulator the following exception is thrown:

file:///app/tns_modules/nativescript-local-notifications/local-notifications.js:26:37: JS ERROR ReferenceError: Can't find variable: Notification

I tested to see if it worked on my iphone and it does with no issues.

my setup:

Simulator: Version 9.3 (SimulatorApp-645.9)

"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/router": "3.2.1",
"lodash": "^4.16.6",
"nativescript-angular": "1.2.0",
"nativescript-intl": "~0.0.8",
"nativescript-local-notifications": "^1.2.0",
"punycode": "1.3.2",
"querystring": "0.2.0",
"rxjs": "5.0.0-beta.12",
"tns-core-modules": ">=2.5.0 || >=2.5.0-2016",
"url": "0.10.3"
},
"devDependencies": {
"nativescript-dev-typescript": "^0.3.2",
"@types/lodash": "^4.14.37",
"typescript": "~2.0.3",
"zone.js": "^0.6.21"
}

No notifications on my iPhone

Works great on android and ios emulators, but when I deploy to my actual iphone no notifications are happening. I can see in the xcode console that the events are firing, but I don't see any notification on the device. Any clues? What could be different?

Snapshotting a view that has not been rendered results in an empty snapshot.

On ios, when I press the home button to send the app to the background, I get this in the console:

 Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

Even if all I do is require the plugin it still happens:

var notifications = require("nativescript-local-notifications");`

Any ideas what is going on here?

Otherwise, notifications are working, but there is one strange behavior, which I also mentioned in #1. Could it be related?

Xcode 8 issue - JS ERROR TypeError: NSNotificationCenter.defaultCenter is not a function.

Thanks for the very handy module!

I upgraded to Xcode 8 and Nativescript 2.3.0, and I'm using 1.1.2 of this module.

My app is crashing as soon as the module is referenced. I tried installing your demo app with the following in the package.jspn file:

{
    "nativescript": {
        "id": "org.nativescript.localnotifications",
        "tns-android": {
            "version": "2.3.0"
        },
        "tns-ios": {
            "version": "2.3.0"
        }
    },
    "dependencies": {
        "nativescript-local-notifications": "1.1.2",
        "tns-core-modules": "2.3.0"
    },
    "devDependencies": {
        "babel-traverse": "6.8.0",
        "babel-types": "6.8.1",
        "babylon": "6.8.0",
        "filewalker": "0.1.2",
        "lazy": "1.0.11",
        "nativescript-dev-typescript": "^0.3.1",
        "typescript": "^1.8.2"
    }
}

The app builds and then crashes with the following error:

Sep 17 08:30:10 raef LocalNotifications[28139]: file:///app/tns_modules/nativescript-local-notifications/local-notifications.js:4:44: JS ERROR TypeError: NSNotificationCenter.defaultCenter is not a function. (In 'NSNotificationCenter.defaultCenter()', 'NSNotificationCenter.defaultCenter' is an instance of NSNotificationCenter)
Sep 17 08:30:10 raef com.apple.CoreSimulator.SimDevice.A02F4667-157D-4C2F-8665-8DBA15F8995C.launchd_sim[19818] (UIKitApplication:org.nativescript.localnotifications[0x9b6a][28139]): Service exited due to Segmentation fault: 11

This is the same error I am getting in my project.

Any ideas?

BigTextStyle for Android

Hey @EddyVerbruggen,
I want to show multiline message in Notifications.
There is already an entry on stackoverflow on this topic.
Link:
https://stackoverflow.com/questions/45666384/firebase-push-notification-how-to-show-multiline-message-in-notification
I have extended your plugin therefore. I added the BigTextStyle as a style for Android.
Could you give me the permission to push my adjustments into the master?
I have already tested my adjustments. I've already pushed the adjustments in my fork.
I would like to share my adjustments.

Here are my changes:
local-notifications-common.js

LocalNotifications.defaults = {
id: 0,
title: '',
body: '',
badge: 0,
interval: 0,
ongoing: false,
groupSummary:null,
bigTextStyle: false
};

local-notifications.d.ts

export interface ScheduleOptions {
...
bigTextStyle?: boolean;

local-notifications.android.js

LocalNotifications.schedule = function (arg) {
...
if(options.bigTextStyle){
var bigTextStyle = new android.support.v4.app.NotificationCompat.BigTextStyle();
bigTextStyle.setBigContentTitle(options.title);
bigTextStyle.bigText(options.body);
builder.setStyle(bigTextStyle);
}

Best regards
Tim

Android foreground/background check

Hello,

Thank you very much for the work on this!

I have the feeling that this is going to be an incredibly n00bish question but here goes:

I am having some trouble getting notifications to trigger/not trigger depending on what page is active in a chat app. So far, I have managed to respond to whether I am on the correct page in the app, but not also if the app is in the foreground or background. How can I also check that?

Code:

// if the notifications is from the user currently represented in the chat view, just update the chat view via the newMessageReceived event on that page
if (frameModule.topmost().currentEntry.context.chatRef === messageSenderId) {
frameModule.topmost().currentPage.notify({
eventName: 'newMessageReceived',
object: this
});
} else {
// schedule notification
LocalNotifications.schedule([{
id: randomNotificationId,
title: 'App Title',
body: 'You have a new message from ' + messageSender
}]).then(() => {
notificationListenerInit(messageSenderId);
}, error => {
console.log('error');
});
}

The conditional here works fine except for when the app is in the background AND the active page is still the one for this chat partner. Obviously the notification should always trigger while the app is in the background, but how do I do that?

Submitted app returned for errors – Unexpected CFBundleExecutable Key

Hi @EddyVerbruggen ,

I got my app returned after uploading it to App Store with the following message:

Dear developer,

We have discovered one or more issues with your recent delivery for "XXXXX". To process your delivery, the following issues must be corrected:

Unexpected CFBundleExecutable Key - The bundle at '/Payload/mobile.app/app/tns_modules/nativescript-local-notifications/native-src/ios/LocalNotificationsPlugin/Info.plist' does not contain a bundle executable. If this bundle intentionally does not contain an executable, consider removing the CFBundleExecutable key from its Info.plist and using a CFBundlePackageType of BNDL. If this bundle is part of a third-party framework, consider contacting the developer of the framework for an update to address this issue.

Unexpected CFBundleExecutable Key - The bundle at '/Payload/mobile.app/app/tns_modules/nativescript-local-notifications/native-src/ios/LocalNotificationsPluginTests/Info.plist' does not contain a bundle executable. If this bundle intentionally does not contain an executable, consider removing the CFBundleExecutable key from its Info.plist and using a CFBundlePackageType of BNDL. If this bundle is part of a third-party framework, consider contacting the developer of the framework for an update to address this issue.

Once these issues have been corrected, you can then redeliver the corrected binary.

Regards,

The App Store team

Can you please advise?

Set Icon and kill already send notifications

Hi.
Thanks for the good plugin.

I wounder if it is possible to set the Icon that is uses in the notification manually?
And it would by nice to kill an already send notification - so it can by used as some kind of status update.

Nicky

Everything is fine... But Notification doesn't show up.

I installed the plugin for Nativescript 2.4 (Android).
So far I used the demo code and everything seemed fine.

I also got the console.log, that the Notification is scheduled.
But there is no Notification showing up... And I don't get any errors...

Someone experiencing the same problem? Is there a solution?

  LocalNotifications.schedule([{
    id: 1,
    title: 'The title',
    body: 'Recurs every minute until cancelled',
  }]).then(
      function() {
        console.log("Notification scheduled");
      },
      function(error) {
        console.log("scheduling error: " + error);
      }
  )

How to disabled notification sound

How do i disabled sound, but still receive notifications

LocalNotifications.schedule([{
id: message.entityId,
title: message.title,
body: message.body,
smallIcon: 'res://icon',
largeIcon: 'res://icon'
}]).then(() => {
console.log("Notification Scheduled");
},(error)=> {
console.log("doScheduleId5 error: " + error);
}
);

Thank you

Error in LocalNotifications.requestPermission

HI

I have just started receiving this error

LocalNotifications.requestPermission : TypeError: null is not an object (evaluating 'app.currentUserNotificationSettings')

I am little confused as it has been previously working :(

Seg 11 fail. Reference to released object

https://github.com/EddyVerbruggen/nativescript-local-notifications/blob/master/native-src/ios/LocalNotificationsPlugin/NotificationManager.m#L107

Somewhere in the if statement on line 107 in NotificationManager.m there is a pointer to a released object when receiving notifications on iOS9.3 and older. This makes the app crash when a notification is received while foreground or when tapping a notification when the application is running background. Removing the if-statement completely solves it

Stopped working after upgrade to xcode 8.2

I upgraded to xcode 8.2 and pods 1.2.0, and now the app crashes when calling;

		LocalNotifications.requestPermission();

Feb 23 12:47:14 com.apple.CoreSimulator.SimDevice.D77BFD9C-7748-4857-9A08-4F8F4F0D8838.launchd_sim[81199] (UIKitApplication:com.xyz.test[0x2be6][84445]): Service exited due to Segmentation fault: 11

Thanks

users notifications

i know this not the right place for this issue but i really need to know how to make users notifications
like if someone liked your post it notify you about that or if someone started following you etc
how can i implement that
thanks

Notification show with small delay

First of all, thank you very much for your work!

My problem is not very crucial, but I think that it is something that can be improved.

When I schedule a notification for 'now' (the default) the notification takes a while to show, usually about 2 - 3 seconds.

LocalNotifications.addOnMessageReceivedCallback not called if app was stopped

I've been trying to figure out this for quite some time. The plugin works very well, but in this scenario I can't seem to make it work.

  1. Schedule a local notification
  2. Stop the app (remove from running in Android/iOS)
  3. Notification appears in the notification bar (both Android & iOS)
  4. Click on notification starts the app
  5. LocalNotifications.addOnMessageReceivedCallback is not called

Versions:
{N} 2.5.0
Plugin: 1.2.1

LocalNotifications.addOnMessageReceivedCallback(data => {
  alert('Id: '+data.id+' Title: '+data.title);
})

// Do I need to register it before or after is ok as well?
platformNativeScriptDynamic().bootstrapModule(AppModule);

The scenario I have requires to get notification data in order to show other screen then home.

Large Notification Icon Spec (Improve Docs)

Hello Eddy,

please consider adding following spec somewhere to the docs. LocalNotifications may fail silently on some android devices (especially Samsung) and never show up if the large icon size is not correct / too big. (Default fallback icon = Launcher icon xxxhdpi size: 345 x 345 which is too big and causes a silent fail. Well not completely silent: logcat -> !!! FAILED BINDER TRANSACTION !!! (parcel size = 1435376))

Large Notification Icon Spec

bildschirmfoto 2017-04-25 um 17 22 13

Don't include xxxhdpi

xxxhdpi: Extra-extra-extra-high-density uses (launcher icon only, see the note in Supporting Multiple Screens); approximately 640dpi. Added in API Level 18
Source: Density Qualifier Docs

Angular nativescript - android

Hi,

It is a way to use it with angular? I've tried to define it in main.ts file, in one in my compontent and event if LocalNotification as a module works fine (I can schedule a notification, get ids of already scheduled etc) but in any case I can`t get application after closing my app :/

Disable App Idle State

Hi,

If app goes to background state, after some time app will reach the idle state. How to stop the app that reaches idle state and remains in the background state. Please help us to achieve this.

Thanks & Regards,
Mani

Unable to get notification icon

  LocalNotifications.schedule([{
    id: 1,
    title: 'The title',
    body: 'Recurs every minute until cancelled',
    ticker: 'The ticker',
    badge: 1,
    smallIcon: 'res://heart.png',
    interval: 'minute',
    sound: null, // suppress the default sound
    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);
      }
  )

Error on android build Grocery tutorial + nativescript-googlemaps-plugin

I'm playing around with NS Grocery Angular+Typescript app tutorial and trying to integrate nativescript-google-maps plugin on it just using the same map component code. It all works fine on iOs emulator, but when trying to build on Android emulator (API 25) i get a build failure (Execution failed for task ':buildMetadata').

This is my 'tns build android' output:

Executing before-prepare hook from /Users/marcogagliardi/Projects/NativeScript/Groceries/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/marcogagliardi/Projects/NativeScript/Groceries/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.2.2
Preparing project...
Project successfully prepared (android)
Executing after-prepare hook from /Users/marcogagliardi/Projects/NativeScript/Groceries/hooks/after-prepare/nativescript-dev-android-snapshot.js
Building project...

:config phase:  createDefaultIncludeFiles
        +found plugins: nativescript-google-maps-sdk
        +found plugins: tns-core-modules-widgets

:config phase:  createPluginsConfigFile
         Creating product flavors include.gradle file in /Users/marcogagliardi/Projects/NativeScript/Groceries/platforms/android/configurations folder...

:config phase:  pluginExtend
        +applying configuration from: /Users/marcogagliardi/Projects/NativeScript/Groceries/platforms/android/configurations/include.gradle
        +applying configuration from: /Users/marcogagliardi/Projects/NativeScript/Groceries/platforms/android/configurations/nativescript-google-maps-sdk/include.gradle
        +applying configuration from: /Users/marcogagliardi/Projects/NativeScript/Groceries/platforms/android/configurations/tns-core-modules-widgets/include.gradle

:config phase:  addAarDependencies
        +adding dependency: /Users/marcogagliardi/Projects/NativeScript/Groceries/platforms/android/libs/aar/widgets-release.aar
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
Incremental java compilation is an incubating feature.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_9kie10nwkgwmdz6d4v90ppg8z.run(/Users/marcogagliardi/Projects/NativeScript/Groceries/platforms/android/build-tools/android-static-binding-generator/build.gradle:126)
:preBuild UP-TO-DATE
:preF0F1DebugBuild UP-TO-DATE
:checkF0F1DebugManifest
:preF0F1ReleaseBuild UP-TO-DATE
:prepareComAndroidSupportAnimatedVectorDrawable2531Library UP-TO-DATE
:prepareComAndroidSupportAppcompatV72531Library UP-TO-DATE
:prepareComAndroidSupportDesign2531Library UP-TO-DATE
:prepareComAndroidSupportRecyclerviewV72531Library UP-TO-DATE
:prepareComAndroidSupportSupportCompat2531Library UP-TO-DATE
:prepareComAndroidSupportSupportCoreUi2531Library UP-TO-DATE
:prepareComAndroidSupportSupportCoreUtils2531Library UP-TO-DATE
:prepareComAndroidSupportSupportFragment2531Library UP-TO-DATE
:prepareComAndroidSupportSupportMediaCompat2531Library UP-TO-DATE
:prepareComAndroidSupportSupportV42531Library UP-TO-DATE
:prepareComAndroidSupportSupportVectorDrawable2531Library UP-TO-DATE
:prepareComAndroidSupportTransition2531Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesBase1100Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesBasement1100Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesMaps1100Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesTasks1100Library UP-TO-DATE
:prepareGroceriesRuntimeUnspecifiedLibrary UP-TO-DATE
:prepareWidgetsReleaseLibrary UP-TO-DATE
:prepareF0F1DebugDependencies
:compileF0F1DebugAidl UP-TO-DATE
:compileF0F1DebugRenderscript UP-TO-DATE
:generateF0F1DebugBuildConfig UP-TO-DATE
:cleanLocalAarFiles
:ensureMetadataOutDir
:collectAllJars
:setProperties
:generateTypescriptDefinitions SKIPPED
:copyTypings SKIPPED
:asbg:generateInterfaceNamesList
:asbg:traverseJsFiles
:asbg:runAstParser UP-TO-DATE
:asbg:generateBindings UP-TO-DATE
:generateF0F1DebugResValues UP-TO-DATE
:generateF0F1DebugResources UP-TO-DATE
:mergeF0F1DebugResources UP-TO-DATE
:processF0F1DebugManifest UP-TO-DATE
:processF0F1DebugResources UP-TO-DATE
:generateF0F1DebugSources UP-TO-DATE
:incrementalF0F1DebugJavaCompilationSafeguard UP-TO-DATE
:compileF0F1DebugJavaWithJavac UP-TO-DATE
:compileF0F1DebugNdk UP-TO-DATE
:compileF0F1DebugSources UP-TO-DATE
:buildMetadata
Exception in thread "main" java.lang.IllegalArgumentException: Class android.support.graphics.drawable.AnimatedVectorDrawableCompat$AnimatedVectorDrawableCompatState conflict: /Users/marcogagliardi/Projects/NativeScript/Groceries/platforms/android/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.3.1/jars/classes.jar and /Users/marcogagliardi/Projects/NativeScript/Groceries/platforms/android/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.2.0/jars/classes.jar
        at com.telerik.metadata.ClassRepo.addToCache(ClassRepo.java:21)
        at com.telerik.metadata.Builder.build(Builder.java:38)
        at com.telerik.metadata.Generator.main(Generator.java:44)
:buildMetadata FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildMetadata'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.983 secs
Command ./gradlew failed with exit code 1

Notifications fails to schedule with Workers [Android]

I'm currently using a worker to schedule local notifications it works fine on IOS but fails with the following log Error in LocalNotifications.schedule: TypeError: Cannot read property 'getResources' of undefined on Android

New option to pass to the schedule function

Would it be possible to have a new option that gives a frequency to the interval? For example if the frequency was 2 and interval was weeks then the the notification would appear every 2 weeks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.