[TIMOB-23128] iOS: Add missing local notification properties
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Medium |
| Status | Closed |
| Resolution | Duplicate |
| Resolution Date | 2016-07-26T09:50:24.000+0000 |
| Affected Version/s | Release 5.2.1 |
| Fix Version/s | n/a |
| Components | iOS |
| Labels | ios, localnotification |
| Reporter | Hans Knöchel |
| Assignee | Hans Knöchel |
| Created | 2016-03-31T11:05:38.000+0000 |
| Updated | 2016-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
PR: https://github.com/appcelerator/titanium_mobile/pull/7899
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 });I am unable to get a notification with region added, adding my demo code below; *app.js*
*Reopening ticket*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)); });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
[~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 :).
Many many silly mistakes in that PR. First of all, use this demo-code:
I also pushed changes to the master-PR, adding it to the backport as soon as it works on master.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" } }); }Removing from review for 5.4.0 because of the
regionissue. I possibly fix it as part of the TIMOB-23527 effort. [~cng] fyi