Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just Fires Once #1192

Closed
ammichael opened this issue Jan 17, 2017 · 28 comments
Closed

Just Fires Once #1192

ammichael opened this issue Jan 17, 2017 · 28 comments

Comments

@ammichael
Copy link

ammichael commented Jan 17, 2017

Your Environment

Plugin version: de.appplant.cordova.plugin.local-notification 0.8.5-dev
Platform: iOS
OS version: 10.2 (14C92)
Device manufacturer / model: iPhone 6 - MG3H2BR/A
Cordova version (cordova -v): 6.3.1
Cordova platform version (cordova platform ls): ios 4.2.1

Expected Behavior

Notifications should be triggered at the time

Actual Behavior

I build and install the app in my device, and when I open for the first time and schedule the notifications, them works fine.

The first schedule works; if I schedule just one notification, this one will works. If I scheduled 3 at once, all the 3 will be fired, but if I schedule again, nothing happens

But them just works once. Reinstalling the app have the same effect; works the first time.

Steps to Reproduce

Scheduling code:

var testNotification = function(){
    var notif = [
      {
        title: "One",
        text: "Text",
        at: new Date(new Date().getTime() + (10 * 1000)),
        id: 991
      },
      {
        title: "Two",
        text: "Text",
        at: new Date(new Date().getTime() + (30 * 1000)),
        id: 992
      },
      {
        title: "Three",
        text: "Text",
        at: new Date(new Date().getTime() + (50 * 1000)),
        id: 993
      },
    ]
    $cordovaLocalNotification.schedule(notif);
  }

When I try to log:

$cordovaLocalNotification.getAll()

It shows fine at the first time (which is triggered), but the array show empty then.

Context

Actually I have to schedule repeated notifications, but it's not working, so I'm trying to debug my way out of it.

I'm having issues with this for months ☹️

@Tawpie
Copy link

Tawpie commented Jan 17, 2017 via email

@ammichael
Copy link
Author

Just tried it out. Works exactly the same

@rwillett
Copy link
Collaborator

This works on 10.0. I don't have a phone with 10.2 on it to test this against.

Also what does works just once mean. It only fires the first schedule and not the rest? Or it fires them all but won't repeat if you execute it twice?

The code #1190 works for us, but its very similar to your code.

Does the fact you're calling $cordovaLocalNotification.schedule(notif); mean you're using a version of the code NOT from this site? We use cordova.plugins.notification.local.scheduleIO

Rob

@ammichael
Copy link
Author

ammichael commented Jan 18, 2017

Means that only the first schedule works; if I schedule just one notification, just this one will works. If I scheduled an array of 3 notifications at once, all the 3 will fire, but if I schedule them again by reopening the app (running the trigger in platform ready), nothing happens.

Also, it doesn't work with "every" attribute.

I've checked the #1190 before opening this issue; they are very similar, but not exactly the same.

I'm calling $cordovaLocalNotification.schedule(notif) because thats how I used before iOS 10 unleash hell upon this plugin. It is ng-cordova. Calling cordova.plugins.notification.local.schedule doesn't work either. I've tried too, but since the first syntax seems better, I kept it.

@rwillett
Copy link
Collaborator

We are doing the same thing and ours works.

Are you definitely incrementing the id to a unique ID and not reusing?

Are you checking and cancelling or checking and NOT cancelling or just cancelling?

We cancel everything before we reschedule or add new schedules in using

        cordova.plugins.notification.local.clear(toClearArray , function() {
            if (debug)
            {
                ConsoleLog("ClearAndCancelLocalNotifications: Clear function success");

		ShowNotificationQueue(); // For Debugging 
            }

            cordova.plugins.notification.local.cancel(toClearArray , function() {
		if (debug)
                {
		    ConsoleLog("ClearAndCancelLocalNotifications: Cancel function success");

                    ShowNotificationQueue();
		}
	    });

Rob

@ammichael
Copy link
Author

@rwillett It's working with iOS 10.2? It works if you use it with 'every' attribute? (If you tried so).

I'm not cancelling, nor clearing anything. I actually do that normally, but right now I'm trying to get it working the simplest possible way, so I just schedule using the code I've posted here, and that is it.

I can try clear and cancel everything, but that seems weird to me.

@rwillett
Copy link
Collaborator

We don't have a 10.2 phone, we have 10.1.1 (14B150).

To summarise, it works on your IOS 10.2 phone the first time, i.e. all three notifications are called but you can't call it twice and get it working the second call?

This should work in the Xcode simulator though, its only push notifications that don't work. have you tried it there?

Rob

@ammichael
Copy link
Author

I've tried the simulator too, and I've got the same behavior. ☹️

@rwillett
Copy link
Collaborator

In 10.1 and 10.2?

@rwillett
Copy link
Collaborator

We've just tested our code the on:

  1. An iPhone 6 running IOS 10.1.1 (14B150)
  2. An iPhone 5d running IOS 8 (12F70)
  3. The Xcode simulator running 10.2 (14C89)

The test fires off four location notifications spread over a few minutes. We were testing on real phones so it was no big deal to try the Xcode simulator.

The tests pass successfully on the two iPhones and the Xcode simulator. Here's the screen shot we took.
screen shot 2017-01-18 at 14 06 35

@ammichael
Copy link
Author

@rwillett Do you schedule them all at once? In an array?

What about setting repeating notifications with every attribute?

@rwillett
Copy link
Collaborator

rwillett commented Jan 19, 2017

Every time we set notifications we set them at once in an array. We work with four or so at a time, though we sometimes send up to 12 or 13 in one of our test cases.

We never use repeating notifications using the every: keyword, we reinsert notifications that get deleted by IOS. Where we have to manage repeating (or rather reinserting) a notification, we do it ourselves. So we don't really repeat a notification but on IOS 8 and 9, when we clear push notifications we also clear the local notifications. Thats an artefact of the clear mechanism on IOS 8/9. So we have to reinsert the local notification at this time. IOS 10 works differently.

#1190 contains the actual code we use in our production app. Its not very difficult and as can be seen from the screen shot above it works. We get four local notifications coming through at the right time on IOS 10.2.

@ammichael
Copy link
Author

@rwillett Got it. Since your code is working, can you at least try setting one test notification to every minute? Just to see what happens?

They should work

@rwillett
Copy link
Collaborator

rwillett commented Jan 24, 2017

On IOS 10, (at: OR firstAt:) AND every: do not work together on IOS 10 and it is unlikely they ever will as Apple appears to have changed their underlying framework. This could well be the problem. Also the current IOS 10 is buggy.

Rob

@ammichael
Copy link
Author

How would you make a use of every: without the at:? Basically, you can't use 'every' anymore. So I thing it should be removed from the official docs and the plugin itself, no?

Anyway, for it still just works only the first time I schedule. I need to reinstall the app, so it works again.. once ☹️

@rwillett
Copy link
Collaborator

The plugin is being rewritten to handle IOS 10. As I understand it, Apple (not @katzer) has changed the way notifications work, the underlying framework has changed and as a result of this, the way notifications will work in the future will be without the combination of at: and every.

@katzer is busy updating the plugin to properly work with IOS 10. I suspect that the documentation is low down on his to-do list. It may be removed from the local notification plugin when it is released.

Since I don't use every: I cannot comment on how it is used with at:. However @katzer was clear that the new IOS 10 framework from Apple doesn't allow it. Beyond that I can't say.

Rob

@ammichael
Copy link
Author

That is really nice to know; that @katzer is updating it.

Anyway, despite the every attribute, returning to this issue, I'm not using every, and still is not working.

@rwillett
Copy link
Collaborator

rwillett commented Jan 24, 2017

I'm out of ideas now.

@ammichael
Copy link
Author

Just to report it here:

I created a new Ionic Project from scratch, installed the ios10 branch and it worked fine. Of course it didn't work with every attribute , but at least it worked every time I opened the app; so I can assume it should be something in my code? Or in my plugins, maybe?

@rwillett
Copy link
Collaborator

If it works in a simple app then its your code or some sort of plugin conflict.

We have no idea what plugins you are using or the rest of your code, so there may be something in there.

Start simply and work up adding functionality in. It does work (sans every:) as we can attest.

@ammichael
Copy link
Author

The thing is.. this is very strange; the code WAS working. The version in App Store works fine for most, but some now and then I receive email from users saying that is not receiving the notifications.

Now I'm trying to isolate plugins and checking any kind of incompatibility between them.

@rwillett
Copy link
Collaborator

Plugins versions?
IOS Versions?
Sub IOS Versions?
Code changes?

@ammichael
Copy link
Author

My plugins:

cc.fovea.cordova.purchase 6.0.0 "Purchase"
cordova-plugin-3dtouch 1.3.5 "3D Touch"
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-badge 0.7.4 "Badges"
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-datepicker 0.9.2 "DatePicker"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-device-motion 1.2.2 "Device Motion"
cordova-plugin-dialogs 1.3.0 "Notification"
cordova-plugin-email-composer 0.8.3 "EmailComposer"
cordova-plugin-globalization 1.0.4 "Globalization"
cordova-plugin-inappbrowser 1.5.0 "InAppBrowser"
cordova-plugin-listpicker 2.2.2 "ListPicker"
cordova-plugin-registerusernotificationsettings 1.0.2 "RegisterUserNotificationSettings"
cordova-plugin-shake 0.5.4 "Shake Gesture Detection"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-statusbar 2.2.0 "StatusBar"
cordova-plugin-vibration 2.1.2 "Vibration"
cordova-plugin-whitelist 1.3.0 "Whitelist"
cordova-plugin-wkwebview-engine 1.1.1-dev "Cordova WKWebView Engine"
cordova-plugin-x-socialsharing 5.1.3 "SocialSharing"
cordova-sqlite-storage 1.4.9 "Cordova sqlite storage plugin"
de.appplant.cordova.plugin.local-notification 0.8.5-dev "LocalNotification"
ionic-plugin-keyboard 2.2.1 "Keyboard"

iOS Version: 10.2.1 (14D27)

No code changes that justify the issue of firing just once

@Tawpie
Copy link

Tawpie commented Jan 30, 2017 via email

@ammichael
Copy link
Author

@Tawpie there are some differences between some plugins, but they shouldn't matter. Maybe, MAYBE, it could be related to the WKWebView. Gonna try removing it and see what happens.

Also, I've tried to use this same branch in Android and it couldn't find the plugin. The console log just showed as undefined.

@rwillett
Copy link
Collaborator

We have similar plugins but not the same. We have never used the WKWebView plugin though.

com.jcesarmobile.IDFVPlugin 1.0.0 "Identifier For Vendor Plugin"
com.rwillett.cordova.plugin.keychainutil 2.0.1 "KeyChain Plugin for Cordova iOS (No iCloud Sync)"
com.transistorsoft.cordova.background-geolocation 2.1.3 "BackgroundGeolocation"
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-background-fetch 4.0.0 "CDVBackgroundFetch"
cordova-plugin-badge 0.7.2 "Badges"
cordova-plugin-battery-status 1.1.1 "Battery"
cordova-plugin-cocoalumberjack 0.0.1 "CocoaLumberjack"
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-dialogs 1.3.0 "Notification"
cordova-plugin-email 1.2.6 "EmailComposer"
cordova-plugin-insomnia 4.2.0 "Insomnia (prevent screen sleep)"
cordova-plugin-network-information 1.1.0 "Network Information"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-vibration 2.0.0 "Vibration"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-plugin-x-toast 2.5.1 "Toast"
cordova-sqlite-storage 0.7.14 "Cordova sqlite storage plugin"
de.appplant.cordova.plugin.local-notification 0.8.5-dev "LocalNotification"
hu.dpal.phonegap.plugins.UniqueDeviceID 1.2.0 "UniqueDeviceID"
ionic-plugin-keyboard 2.2.1 "Keyboard"
pushwoosh-cordova-plugin 6.4.1 "Pushwoosh"

@ammichael
Copy link
Author

ammichael commented Feb 27, 2017

Hey guys, I've created a new ionic project and migrated the code to the new one (weird since I've tried resetting platform settings, and didn't work). Now it's working fine as long as I don't use every , which is a deal breaker for me.

Is there a reason for the every doesn't work anymore? Is it being fixed or will it be removed?

Thanks

@rwillett
Copy link
Collaborator

The reason is that every: is not supported on IOS 10 and will not be supported by Apple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants