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

Ios10 #22

Closed
wants to merge 2 commits into from
Closed

Ios10 #22

wants to merge 2 commits into from

Conversation

oleklapp
Copy link
Contributor

Rewritten to work with the new iOS10 UNNotificationCenter.
To enable the application to show and handle notifications while in the foreground, the following will have to be added to the app.js file:

if (application.ios) {

    var __extends = this.__extends || function (d, b) {
        for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
        function __() { this.constructor = d; }
        __.prototype = b.prototype;
        d.prototype = new __();
    };

    var appDelegate = (function (_super ) {

        __extends(appDelegate, _super);

        function appDelegate() {
            _super.apply(this, arguments);
        }

        appDelegate.prototype.userNotificationCenterDidReceiveNotificationResponseWithCompletionHandler = function(center, notif, completion){
            completion();
        }

        appDelegate.prototype.userNotificationCenterWillPresentNotificationWithCompletionHandler = function(center, notif, completion){
            completion(4);  // 4 is equal to UNNotificationPresentationOptions.Alert
        }    

        appDelegate.prototype.applicationDidFinishLaunchingWithOptions = function (application, launchOptions) {

            // Assign the delegate to UNUserNotificationCenter. This allows the application to receive notifications while in foreground
            var center = utils.ios.getter(UNUserNotificationCenter, UNUserNotificationCenter.currentNotificationCenter);
            center.delegate = this; 

        };

        appDelegate.ObjCProtocols = [UIApplicationDelegate, UNUserNotificationCenterDelegate];
        return appDelegate;

    })(UIResponder);

    application.ios.delegate = appDelegate;

}

Rewritten to use the new iOS10 UNNotificationCenter. Added ability to choose between UNCalendarNotificationTrigger and UNTimeIntervalNotificationTrigger which allows the user to either schedule by seconds in the future or by a specific datetime.
Added the posibility to set repeat (boolean) and choose between UNTimeIntervalNotificationTrigger and UNCalendarNotificationTrigger as a triggering function
@rijine
Copy link

rijine commented Apr 25, 2017

@EddyVerbruggen can u please verify this pull request. IOS 10, local notification isn't working.

@EddyVerbruggen
Copy link
Owner

iOS 10 worked fine with this plugin. iOS 11 even. But indeed it's a deprecated framework and will probably be removed in iOS 15 or so.

Version 3.0.0 is a rewrite and uses UNNotificationCenter which was introduced with iOS 10, and I've added interactive notifications (buttons and text input) as a bonus. And the possibility to show a local notification on iOS when the app is in the foreground.

Note that I could not merge this PR because it would break compatibility with iOS 9 and lower.

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

Successfully merging this pull request may close these issues.

None yet

3 participants