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

Notification not triggered on ios #1200

Closed
OlegWarkentinWeb opened this issue Jan 25, 2017 · 14 comments
Closed

Notification not triggered on ios #1200

OlegWarkentinWeb opened this issue Jan 25, 2017 · 14 comments

Comments

@OlegWarkentinWeb
Copy link

Environment

Plugin version: 0.8.5-dev
Platform: iOS
OS version: 10.0.2
Device manufacturer / model: Apple / ME432DN/A
Cordova version : cli-6.3.0

Actual Behavior

Tell us what happens instead:
Notification not triggered on ios

Steps to Reproduce

Here is my code

` cordova.plugins.notification.local.hasPermission(function (granted) {
if (granted == true) {
schedule();
}
else {
cordova.plugins.notification.local.registerPermission(function (granted) {
if (granted == true) {
schedule();
}
else {
navigator.notification.alert("Keine Berechtigung erteilt!");
}
});
}
});

function schedule() {
    var h;
    var m;
    var id = 1;

    for (var i = 0; i < events.length; i++) {
        if (events[i].kalenderID == "1") {
            h = _kalender1.zeit.substr(0, 2); //22 for example
            m = _kalender1.zeit.substr(3, 2); //15 for example
        }

        if (h != "") {
            var date = new Date(events[i].datum);
            var dateWithTime = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1, h, m, 0); // Mon Jan 30 2017 00:58:00 GMT+0100 (Mitteleuropäische Zeit)
            var abfallText = "xxx";

            pushAppointments.push({
                id: id,
                title: "Stratmann",
                text: "Nicht vergessen! Stellen Sie bitte " + abfallText + " für " + events[i].ort + " raus.",
                every: 'year',
                at: dateWithTime
                }
            );

            id++;
        }
    }

    cordova.plugins.notification.local.schedule(pushAppointments);
}`

Context

Can you help me pls? Its for a Client...

Best regards
Oleg

@rwillett
Copy link
Collaborator

There appears to be issues with every: and at: on IOS 10 with this branch.

Pull out the every: and check that it works with the at: first of all. If it works there, then it appears there is a problem.

Rob

@OlegWarkentinWeb
Copy link
Author

Hi Rob,

thank you very much for the fast reply!

I tested without every - but didnt work too.
Asking for permission is triggered but no push notification comes.

Any other idea?

Thank you!

Oleg

@rwillett
Copy link
Collaborator

This seems to be an ongoing problem with later versions of IOS 10. AFAIK our code works with the codebase but a lot of other peoples doesn't. We tested it on the IOS simulator for 10.2 a few days ago and it works there. See #1192 for screen shots and #1190 for the actual production code we use.

I suspect there is a problem with the plugin and certain versions of IOS but since I'm not the author I can't comment any more on what it might be.

I'm at a loss as it works for us.

@OlegWarkentinWeb
Copy link
Author

Thank you for the information.

I searched for other npm-packages and found this https://github.com/dpalou/cordova-plugin-local-notifications

With this version it works for me on ios 10

@rwillett
Copy link
Collaborator

OK, lets close this issue down then.

Thanks

Rob

@marcelodolza
Copy link

Still not working here, I also tried the fork that @OlegWarkentinWeb mentioned.
Here the following problem occurs, when I ask to register a notification, it only works when I minimize the application and I go back to it, then defrost and shows the notifications in the console debug of xcode.
It's strange because in the previous version of my application the notifications work, including in iOS 10. But now compiling again, it does not work anymore.
Anyone have any idea how to solve it?

@rwillett
Copy link
Collaborator

Something is wrong in your code.

Show some code and also what does defrost mean.

@marcelodolza
Copy link

@rwillett, the code is the same. I did not change anything, I only compiled months later with new updates of the Cordova and the plugins.
Does the notification work for me only when the app is minimized and then open.

@rwillett
Copy link
Collaborator

Then something else has changed, e.g. the IOS version. It does look as if the IOS 10.2.1 is causing lots of issues.

@marcelodolza
Copy link

I found the solution. Apparently the problem of freezing was the CSP rules.
Now I had to add: gap://ready

<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *">

@rwillett
Copy link
Collaborator

Ok. Had these changed or had you added the whitelist plugin?

@marcelodolza
Copy link

I already had it on project the whitelist plugin, but must have been updated. So I just changed this line in index.html.

@rwillett
Copy link
Collaborator

If we have found the issue lets close this thread down.

Thanks

Rob

@rwillett
Copy link
Collaborator

Closed as no update in three weeks.

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

No branches or pull requests

3 participants