question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local notifications not working in ios

See original GitHub issue

WARNING: IF YOU IGNORE THIS TEMPLATE, WE’LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Provide a general summary of the issue.

Your Environment

  • Plugin version: 0.8.5
  • Platform: IOS
  • OS version: 11.1.2
  • Device manufacturer / model: Apple
  • Cordova version (cordova -v): 7.1.0
  • Cordova platform version (cordova platform ls): Installed platforms: android 6.2.2 ios 4.5.4
  • Plugin config
  • Ionic Version (if using Ionic) 2.0.0

Expected Behavior

When the app is in foreground, I want a local notification.

Actual Behavior

No notification arrives but as soon as I take my app in the background, the notification comes.

Steps to Reproduce

I’m using cordova-plugin-fcm for push notifications in case of background and app killed. In case of app in foreground, I’m scheduling local notification using the plugin. This is my code:

            FCMPlugin.onNotification((msg) => {
                this.notificationMsg = msg;
                if (msg.wasTapped) {
                 // code for app background and app killed
                }
                else {
                    LocalNotifications.schedule({
                            id: 1,
                            title: 'title',
                            text: 'text',
                        })
               }
            })

But no local notifications comes up in foreground. But as soon as I minimize the app, it comes. What’s the issue here? Anything to do with plugin version? Please help.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:36 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
uklawittercommented, Jul 28, 2018

Adding “foreground: true” solved this problem for me:

const notification = { id, title, text, silent: false, foreground: true };
this.notifications.schedule(notification);`
0reactions
alitalaeecommented, Nov 2, 2021

@alitalaee My solution is to add some code to cordova-plugin-push, not cordova-plugin-local-notifications

omm yeah… Does it work for ios and android with FCM? how can i use it with FCM can you explain please thanks a lot

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS 10 Local Notifications not showing - Stack Overflow
1 Answer 1 · Make sure you have the permission. If not, use UNUserNotificationCenter.current().requestAuthorization to get that. Or follow the answer below if ......
Read more >
Local Notification not working in Background Mode
When app is in background, notifications wont show. After investigating this issue i found that they work fine when app is running in...
Read more >
Quick guide on local notifications for iOS - tanaschita.com
Learn how to schedule local notifications in different ways and how to handle them. ... iOS local and push notifications allow us to...
Read more >
flutter_local_notifications | Flutter Package - Pub.dev
A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform.
Read more >
iOS Local Notifications not working until after App restart
My stack is Ionic + Vue (v. 5.4.0) and Capacitor (v. 2.4.7). I'm having trouble getting the Local Notifications to trigger properly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found