Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23128] iOS: Add missing local notification properties

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionDuplicate
Resolution Date2016-07-26T09:50:24.000+0000
Affected Version/sRelease 5.2.1
Fix Version/sn/a
ComponentsiOS
Labelsios, localnotification
ReporterHans Knöchel
AssigneeHans Knöchel
Created2016-03-31T11:05:38.000+0000
Updated2016-07-26T09:50:24.000+0000

Description

There are missing two properties inside the Ti.App.iOS.scheduleLocalNotification: * alertTitle: The title of the alert being displayed (alertBody already covered) * region: The region in which the notification can be triggered

Comments

  1. Hans Knöchel 2016-03-31

    PR: https://github.com/appcelerator/titanium_mobile/pull/7899
  2. Angel Petkov 2016-04-01

    Uncomment region upon second run and a notification should not be displayed. Demo code :
        Ti.App.iOS.registerUserNotificationSettings({
       	    types: [
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
               ]
           });
       
       var notification = Ti.App.iOS.scheduleLocalNotification({
           alertTitle: "Feature Test",
           alertAction: "update",
           alertBody: "New content available! Update now?",
           badge: 12,
           date: new Date(new Date().getTime() + 3000),
           sound: "/alert.wav",
           userInfo: { "url":"http://www.download.com/content/asset.json"},
           //region:{latitude:35.6895,longitude:139.6917} //Japan
       }); 
       
  3. Josh Longton 2016-07-07

    I am unable to get a notification with region added, adding my demo code below; *app.js*
        Ti.App.iOS.registerUserNotificationSettings({
       	    types: [
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
               ]
           });
           
           var notification = Ti.App.iOS.scheduleLocalNotification({
           alertTitle: "Feature Test",
           alertAction: "update",
           alertBody: "New content available! Update now?",
           badge: 12,
           date: new Date(new Date().getTime() + 3000),
           sound: "/alert.wav",
           userInfo: { "url":"http://www.download.com/content/asset.json"},
           //region:{latitude:35.6895,longitude:139.6917} //Japan
           region:{latitude:37.36,longitude:-121.91} //office
       }); 
       
       
           var authorization = Titanium.Geolocation.locationServicesAuthorization;
           Ti.API.info('Authorization:' + authorization);
       
           Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
           Titanium.Geolocation.addEventListener('location', function(e) {
               Ti.API.info('Location Update ::' + JSON.stringify(e));
              
           });
       
    *Reopening ticket*
  4. Hans Knöchel 2016-07-08

    PR's to adjust the docs: - master: https://github.com/appcelerator/titanium_mobile/pull/8117 - 5_4_X: https://github.com/appcelerator/titanium_mobile/pull/8118
  5. Angel Petkov 2016-07-11

    [~jlongton] Could you please re-test with the updated docs to make sure you're able to get the local notifications, once confirmed we can resolve and close the ticket :).
  6. Hans Knöchel 2016-07-12

    Many many silly mistakes in that PR. First of all, use this demo-code:
       
       
       var win = Ti.UI.createWindow({
         backgroundColor : "#fff"
       });
        
       var btn = Ti.UI.createButton({
         title : "Schedule notification"
       });
       
       Ti.App.iOS.addEventListener('notification', function(e) {
           alert("Received!");
       });
       
       btn.addEventListener("click", function() {
           if (!Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS)) {
               Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
                   if (!e.success) {
                       Ti.API.error("No permissions granted!");
                       return;
                   }
                   
                   scheduleNotification();
               })
           } else {
               scheduleNotification();
           }
       });
       
       win.add(btn);
       win.open();
       
       function scheduleNotification() {
           Ti.App.iOS.cancelAllLocalNotifications();
           Ti.App.iOS.registerUserNotificationSettings({
               types: [
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
                   Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
               ]
           });
               
           var notification = Ti.App.iOS.scheduleLocalNotification({
               alertTitle: "Feature Test",
               alertAction: "update",
               alertBody: "New content available! Update now?",
               badge: 12,
               userInfo: { "url":"http://www.download.com/content/asset.json"},
               region:{
                   latitude: 52.672,
                   longitude: 7.299,
                   radius: 10000,
                   triggersOnce: false,
                   identifier: "WTF"
               }
           }); 
       }
       
    I also pushed changes to the master-PR, adding it to the backport as soon as it works on master.
  7. Hans Knöchel 2016-07-18

    Removing from review for 5.4.0 because of the region issue. I possibly fix it as part of the TIMOB-23527 effort. [~cng] fyi

JSON Source