11var LocalNotifications = require ( "./local-notifications-common" ) ;
2+ var utils = require ( "utils/utils" ) ;
23
34LocalNotifications . _addObserver = function ( eventName , callback ) {
4- return NSNotificationCenter . defaultCenter ( ) . addObserverForNameObjectQueueUsingBlock ( eventName , null , NSOperationQueue . mainQueue ( ) , callback ) ;
5+ var notiCenter = utils . ios . getter ( NSNotificationCenter , NSNotificationCenter . defaultCenter ) ;
6+ var queue = utils . ios . getter ( NSOperationQueue , NSOperationQueue . mainQueue ) ;
7+ return notiCenter . addObserverForNameObjectQueueUsingBlock ( eventName , null , queue , callback ) ;
58} ;
69
710var pendingReceivedNotifications = [ ] ,
@@ -13,16 +16,15 @@ var pendingReceivedNotifications = [],
1316 // grab 'em here, store em in JS, and give them to the callback when addOnMessageReceivedCallback is wired
1417 LocalNotifications . notificationReceivedObserver = LocalNotifications . _addObserver ( "notificationReceived" , function ( result ) {
1518 var notificationDetails = JSON . parse ( result . userInfo . objectForKey ( 'message' ) ) ;
16- console . log ( "------- notificationReceivedObserver: " + notificationDetails ) ;
1719 if ( receivedNotificationCallback !== null ) {
1820 receivedNotificationCallback ( notificationDetails ) ;
1921 } else {
2022 pendingReceivedNotifications . push ( notificationDetails ) ;
2123 }
2224 } ) ;
2325
24- notificationHandler = Notification . alloc ( ) . init ( ) ;
25- notificationManager = NotificationManager . alloc ( ) . init ( ) ;
26+ notificationHandler = Notification . new ( ) ;
27+ notificationManager = NotificationManager . new ( ) ;
2628} ) ( ) ;
2729
2830LocalNotifications . addOnMessageReceivedCallback = function ( callback ) {
@@ -75,7 +77,8 @@ LocalNotifications.requestPermission = function (arg) {
7577LocalNotifications . _requestPermission = function ( callback ) {
7678
7779 LocalNotifications . didRegisterUserNotificationSettingsObserver = LocalNotifications . _addObserver ( "didRegisterUserNotificationSettings" , function ( result ) {
78- NSNotificationCenter . defaultCenter ( ) . removeObserver ( LocalNotifications . didRegisterUserNotificationSettingsObserver ) ;
80+ var notiCenter = utils . ios . getter ( NSNotificationCenter , NSNotificationCenter . defaultCenter ) ;
81+ notiCenter . removeObserver ( LocalNotifications . didRegisterUserNotificationSettingsObserver ) ;
7982 LocalNotifications . didRegisterUserNotificationSettingsObserver = undefined ;
8083 var granted = result . userInfo . objectForKey ( 'message' ) ;
8184 callback ( granted != "false" ) ;
@@ -93,7 +96,7 @@ LocalNotifications._schedulePendingNotifications = function () {
9396 for ( var n in pending ) {
9497 var options = LocalNotifications . merge ( pending [ n ] , LocalNotifications . defaults ) ;
9598
96- var notification = UILocalNotification . alloc ( ) . init ( ) ;
99+ var notification = UILocalNotification . new ( ) ;
97100 notification . fireDate = options . at ? options . at : new Date ( ) ;
98101 notification . alertTitle = options . title ;
99102 notification . alertBody = options . body ;
@@ -120,7 +123,6 @@ LocalNotifications._schedulePendingNotifications = function () {
120123 // notification.soundName = custom..;
121124 // notification.resumeApplicationInBackground = true;
122125
123- console . log ( "--- scheduling " + notification ) ;
124126 UIApplication . sharedApplication ( ) . scheduleLocalNotification ( notification ) ;
125127 }
126128} ;
@@ -178,7 +180,6 @@ LocalNotifications.getScheduledIds = function () {
178180LocalNotifications . schedule = function ( arg ) {
179181 return new Promise ( function ( resolve , reject ) {
180182 try {
181- console . log ( "arg: " + JSON . stringify ( arg ) ) ;
182183 LocalNotifications . pendingNotifications = arg ;
183184
184185 if ( ! LocalNotifications . _hasPermission ( ) ) {
0 commit comments