Skip to content

Commit 0be9981

Browse files
authored
Merge pull request #3955 from RKBoss6/iosLocation
[iOS Integration] Add BangleDumpLocation shortcut compatibility
2 parents 16a25f2 + 1469329 commit 0be9981

File tree

4 files changed

+109
-30
lines changed

4 files changed

+109
-30
lines changed

apps/ios/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
0.18: Fix UTF8 conversion (check for `font` library, not `fonts`)
2020
0.19: Convert numeric weather values to int from BangleDumpWeather shortcut
2121
0.20: Add feels-like temperature data field to weather parsing from BangleDumpWeather shortcut.
22+
0.21: Add BangleDumpLocation shortcut, to update location data on watch without needing to use the watch's GPS, and added more app names/ ids.

apps/ios/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,21 @@ for now. It's just a few bucks/pounds/euro's.
3535
If you like to try a free app first, you can always use NRF Toolbox or
3636
Bluetooth BLE Device Finder to find and connect your Bangle.
3737

38-
### Weather and Calendar
38+
### Weather, Calendar, and Location
3939

40-
By using the `Shortcuts` app on your phone, you can send weather and calendar data to your watch. This works by sending a notification, which is read by the watch through ANCS. The watch then parses the notification for the data.
40+
By using the `Shortcuts` app on your phone, you can send weather, calendar, and location data to your watch. This works by sending a notification, which is read by the watch through ANCS. The watch then parses the notification for the data.
4141

42-
While you may write your own shortcuts if you prefer (for example, to get weather from a different source), two are provided:
42+
While you may write your own shortcuts if you prefer (for example, to get weather from a different source), three are provided:
4343

44-
- Calendar shortcut: https://www.icloud.com/shortcuts/4eac12548b4c424dbcdb1bd58cff338f
45-
- Weather shortcut: https://www.icloud.com/shortcuts/106c68bfac3746fe9a55761a3be8d092
44+
- [Calendar shortcut](https://www.icloud.com/shortcuts/4eac12548b4c424dbcdb1bd58cff338f)
45+
- [Weather shortcut](https://www.icloud.com/shortcuts/106c68bfac3746fe9a55761a3be8d092)
46+
- [Location shortcut](https://www.icloud.com/shortcuts/853c41e09a8e491f893a63b464d73ea1)
4647

47-
The weather shortcut requires an OpenWeatherMap api key, which you can get for free from https://openweathermap.org/api. The shortcut will prompt you for this when you add it to your phone.
48+
Note: The shortcuts must keep the names defaulted by the shortcut in order for the watch to detect the weather, calender, or location data. If you rename it from `BangleDump...` to something else, it will no longer get the info, and just display it as a notification on the watch.
4849

4950
These shortcuts can also be automated to run periodically, for example every hour, using the `Automation` tab in the Shortcuts app.
5051

51-
The shortcuts will send a notification, which can be annoying. One potential workaround for this would be to create a focus mode, and have an automation:
52+
The shortcuts will send a notification. Even though the notification is deleted as soon as Bangle.js receives it, it can be quite annoying. One potential workaround for this would be to create a focus mode, and have an automation:
5253
- activate the focus mode (hiding notifications from the shortcut)
5354
- run the shortcut
5455
- deactivate the focus mode
@@ -60,4 +61,9 @@ Please file any issues on https://github.com/espruino/BangleApps/issues/new?titl
6061

6162
## Creator
6263

63-
Gordon Williams
64+
- Gordon Williams
65+
66+
## Contributors
67+
68+
- RKBoss6
69+
- stweedo

apps/ios/boot.js

Lines changed: 91 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,56 @@ E.on('notify',msg=>{
7878
"com.apple.reminders": "Reminders",
7979
"com.apple.shortcuts": "Shortcuts",
8080
"com.apple.TestFlight": "TestFlight",
81-
"com.apple.ScreenTimeNotifications": "ScreenTime",
81+
"com.apple.ScreenTimeNotifications": "Screen Time",
8282
"com.apple.wifid.usernotification": "WiFi",
83+
"com.apple.Maps": "Maps",
84+
"com.apple.Music": "Apple Music",
85+
"com.apple.AppStore": "App Store",
86+
"com.apple.Preferences": "Settings",
87+
"com.apple.calculator": "Calculator",
88+
"com.apple.camera": "Camera",
89+
"com.apple.weather": "Weather",
90+
"com.apple.VoiceMemos": "Voice Memos",
91+
"com.apple.News": "News",
92+
"com.apple.tv": "Apple TV",
93+
"com.apple.findmy": "Find My",
94+
"com.apple.compass": "Compass",
95+
"com.apple.measure": "Measure",
8396
"com.atebits.Tweetie2": "Twitter",
84-
"com.burbn.instagram" : "Instagram",
97+
"com.burbn.instagram": "Instagram",
8598
"com.facebook.Facebook": "Facebook",
8699
"com.facebook.Messenger": "Messenger",
87-
"com.google.Chromecast" : "Google Home",
88-
"com.google.Gmail" : "GMail",
89-
"com.google.hangouts" : "Hangouts",
90-
"com.google.ios.youtube" : "YouTube",
91-
"com.hammerandchisel.discord" : "Discord",
92-
"com.ifttt.ifttt" : "IFTTT",
93-
"com.jumbo.app" : "Jumbo",
94-
"com.linkedin.LinkedIn" : "LinkedIn",
100+
"com.google.Chromecast": "Google Home",
101+
"com.google.Gmail": "GMail",
102+
"com.google.hangouts": "Hangouts",
103+
"com.google.ios.youtube": "YouTube",
104+
"com.google.ios.chrome": "Google Chrome",
105+
"com.google.Maps": "Google Maps",
106+
"com.google.Drive": "Google Drive",
107+
"com.google.GoogleMobile": "Google",
108+
"com.hammerandchisel.discord": "Discord",
109+
"com.ifttt.ifttt": "IFTTT",
110+
"com.jumbo.app": "Jumbo",
111+
"com.linkedin.LinkedIn": "LinkedIn",
95112
"com.marktplaats.iphone": "Marktplaats",
96-
"com.microsoft.Office.Outlook" : "Outlook Mail",
97-
"com.nestlabs.jasper.release" : "Nest",
98-
"com.netflix.Netflix" : "Netflix",
99-
"com.reddit.Reddit" : "Reddit",
113+
"com.microsoft.Office.Outlook": "Outlook Mail",
114+
"com.microsoft.Office.Word": "Microsoft Word",
115+
"com.microsoft.Office.Excel": "Microsoft Excel",
116+
"com.microsoft.Office.Powerpoint": "Microsoft PowerPoint",
117+
"com.nestlabs.jasper.release": "Nest",
118+
"com.netflix.Netflix": "Netflix",
119+
"com.reddit.Reddit": "Reddit",
100120
"com.skype.skype": "Skype",
101121
"com.skype.SkypeForiPad": "Skype",
102122
"com.spotify.client": "Spotify",
123+
"com.soundcloud.TouchApp": "SoundCloud",
124+
"com.disney.disneyplus": "Disney+",
125+
"com.hbo.hbonow": "HBO Max",
126+
"com.amazon.Amazon": "Amazon Shopping",
127+
"com.amazon.AmazonVideo": "Prime Video",
128+
"com.dropbox.Dropbox": "Dropbox",
129+
"com.evernote.iPhone.Evernote": "Evernote",
130+
"com.trello": "Trello",
103131
"com.storytel.iphone": "Storytel",
104132
"com.strava.stravaride": "Strava",
105133
"com.tinyspeck.chatlyio": "Slack",
@@ -110,20 +138,22 @@ E.on('notify',msg=>{
110138
"com.valvesoftware.Steam": "Steam",
111139
"com.vilcsak.bitcoin2": "Coinbase",
112140
"com.wordfeud.free": "WordFeud",
113-
"com.yourcompany.PPClient": "PayPal",
141+
"com.paypal.PPClient": "PayPal",
114142
"com.zhiliaoapp.musically": "TikTok",
143+
"com.pinterest": "Pinterest",
144+
"com.tumblr.tumblr": "Tumblr",
115145
"de.no26.Number26": "N26",
116146
"io.robbie.HomeAssistant": "Home Assistant",
117147
"net.superblock.Pushover": "Pushover",
118148
"net.weks.prowl": "Prowl",
119149
"net.whatsapp.WhatsApp": "WhatsApp",
120-
"nl.ah.Appie": "Albert Heijn",
121150
"nl.postnl.TrackNTrace": "PostNL",
122151
"org.whispersystems.signal": "Signal",
123152
"ph.telegra.Telegraph": "Telegram",
124-
"tv.twitch": "Twitch",
125-
// could also use NRF.ancsGetAppInfo(msg.appId) here
126-
};
153+
"tv.twitch": "Twitch"
154+
};
155+
156+
127157

128158
//if (appNames[msg.appId]) msg.a
129159
if (msg.title === "BangleDumpCalendar") {
@@ -191,7 +221,7 @@ E.on('notify',msg=>{
191221
wind: d.wind,
192222
wdir: d.wdir,
193223
loc: d.loc
194-
}
224+
};
195225
// Convert string fields to numbers for iOS weather shortcut
196226
const numFields = ['code', 'wdir', 'temp','feels', 'hi', 'lo', 'hum', 'wind', 'uv', 'rain'];
197227
numFields.forEach(field => {
@@ -201,6 +231,47 @@ E.on('notify',msg=>{
201231
NRF.ancsAction(msg.uid, false);
202232
return;
203233
}
234+
235+
if (msg.title === "BangleDumpLocation") {
236+
237+
const d = JSON.parse(msg.message);
238+
239+
/* Example:
240+
{"lat":"2912.0744", "lon":"2333.332", "city":"Chicago"}*/
241+
let locationJson = {
242+
t: "location",
243+
lat:d.lat,
244+
lon:d.lon,
245+
city:d.city
246+
247+
};
248+
// Convert string fields to numbers
249+
const numFields = ['lat', 'lon'];
250+
numFields.forEach(field => {
251+
if (locationJson[field] != null) locationJson[field] = +locationJson[field];
252+
});
253+
254+
//load mylocation file
255+
let myLocationJson = Object.assign({
256+
lat: d.lat,
257+
lon: d.lon,
258+
location:d.city
259+
}, require("Storage").readJSON("mylocation.json", true) || {});
260+
//remove notification from phone
261+
NRF.ancsAction(msg.uid, false);
262+
if(Math.abs(myLocationJson.lat - locationJson.lat) < 0.0001 && Math.abs(myLocationJson.lon -locationJson.lon) < 0.0001){
263+
//same location, do not write
264+
return;
265+
}
266+
267+
myLocationJson.lon=locationJson.lon;
268+
myLocationJson.lat=locationJson.lat;
269+
myLocationJson.location=locationJson.city;
270+
require("Storage").write("mylocation.json",myLocationJson);
271+
272+
273+
return;
274+
}
204275

205276
require("messages").pushMessage({
206277
t : msg.event,

apps/ios/metadata.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"id": "ios",
33
"name": "iOS Integration",
4-
"version": "0.20",
5-
"description": "Display/pull notifications, music, weather, and agenda from iOS devices",
4+
"version": "0.21",
5+
"description": "Display/pull notifications, music, weather, location, and agenda from iOS devices",
66
"icon": "app.png",
77
"tags": "tool,system,ios,apple,messages,notifications",
88
"dependencies": {"messages":"module"},
9+
"dependencies" : {"mylocation":"app" },
910
"supports": ["BANGLEJS","BANGLEJS2"],
1011
"readme": "README.md",
1112
"storage": [

0 commit comments

Comments
 (0)