Skip to content

Commit

Permalink
ios 0.14: Add settings page, allow time sync
Browse files Browse the repository at this point in the history
      Allow negative/positive actions to pass through to message GUI
  • Loading branch information
gfwilliams committed Oct 6, 2023
1 parent de5fcd2 commit 9c4d905
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
2 changes: 2 additions & 0 deletions apps/ios/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
0.11: Added letters with caron to unicodeRemap, to properly display messages in Czech language
0.12: Use new message library
0.13: Making ANCS message receive more resilient (#2402)
0.14: Add settings page, allow time sync
Allow negative/positive actions to pass through to message GUI
28 changes: 18 additions & 10 deletions apps/ios/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# iOS integration app

This is the iOS integration app for Bangle.js. This app allows you to receive
notifications from your iPhone. The Apple Notification Center Service (ANCS)
sends all the messages to your watch.
notifications from your iPhone. The Apple Notification Center Service (ANCS)
sends all the messages to your watch.

You can allow this if you connect your Bangle to your iPhone. It will be
prompted for immediatly after you connect the Bangle to the iPhone.
You can allow this if you connect your Bangle to your iPhone. It will be
prompted for immediatly after you connect the Bangle to the iPhone.

### Connecting your Bangle(2).js to your iPhone
The Bangle watches are Bluetooth Low Energy (BLE) devices. Sometimes they
will not be seen/detected by the Bluetooth scanner in your iPhone settings
### Setting

Under `Settings -> Apps -> iOS Integration` there is
a `Time Sync` setting. This will enable syncing between the
watch and iOS.

### Connecting your Bangle.js to your iPhone

The Bangle watches are Bluetooth Low Energy (BLE) devices. Sometimes they
will not be seen/detected by the Bluetooth scanner in your iPhone settings
menu.

To resolve this, you can download numerous apps who can actually scan
To resolve this, you can download an app that can actually scan
for BLE devices. There are great ones out there, free and paid.

We really like WebBLE, which we also recommend to load apps on your
watch with your iOS device, as Safari does not support WebBluetooth
We really like WebBLE, which we also recommend to load apps on your
watch with your iOS device, as Safari does not support WebBluetooth
for now. It's just a few bucks/pounds/euro's.

If you like to try a free app first, you can always use NRF Toolbox or
Bluetooth BLE Device Finder to find and connect your Bangle.


## Requests

Please file any issues on https://github.com/espruino/BangleApps/issues/new?title=ios%20app
Expand Down
35 changes: 30 additions & 5 deletions apps/ios/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ E.on('ANCS',msg=>{
function ancsHandler() {
var msg = Bangle.ancsMessageQueue[0];
NRF.ancsGetNotificationInfo( msg.uid ).then( info => { // success

if(msg.preExisting === true){
info.new = false;
} else {
info.new = true;
}

E.emit("notify", Object.assign(msg, info));
Bangle.ancsMessageQueue.shift();
if (Bangle.ancsMessageQueue.length)
Expand Down Expand Up @@ -169,7 +167,9 @@ E.on('notify',msg=>{
new : msg.new,
title : msg.title&&E.decodeUTF8(msg.title, unicodeRemap, replacer),
subject : msg.subtitle&&E.decodeUTF8(msg.subtitle, unicodeRemap, replacer),
body : msg.message&&E.decodeUTF8(msg.message, unicodeRemap, replacer) || "Cannot display"
body : msg.message&&E.decodeUTF8(msg.message, unicodeRemap, replacer) || "Cannot display",
positive : msg.positive,
negative : msg.negative
});
// TODO: posaction/negaction?
});
Expand All @@ -196,7 +196,7 @@ Bangle.musicControl = cmd => {
};
// Message response
Bangle.messageResponse = (msg,response) => {
if (isFinite(msg.id)) return NRF.sendANCSAction(msg.id, response);//true/false
if (isFinite(msg.id)) return NRF.ancsAction(msg.id, response);//true/false
// error/warn here?
};
// remove all messages on disconnect
Expand Down Expand Up @@ -225,16 +225,41 @@ NRF.ancsGetNotificationInfo = function(uid) {
});
};
E.on("notify", n => print("NOTIFY", n));
E.emit("ANCS", {
event:"add",
uid:42,
category:4,
categoryCnt:42,
silent:true,
important:false,
preExisting:true,
preExisting:false,
positive:false,
negative:true
});
*/

{
let settings = require("Storage").readJSON("ios.settings.json",1)||{};
let ctsUpdate = e=>{
if (process.env.VERSION=="2v19")
e.date.setMonth(e.date.getMonth()-1); // fix for bug in 2v19 firmware
var tz = 0;
if (e.timezone!==undefined) {
E.setTimeZone(e.timezone);
tz = e.timezone*3600;
var settings = require('Storage').readJSON('setting.json',1)||{};
settings.timezone = e.timezone;
require('Storage').writeJSON('setting.json',settings);
}
setTime((e.date.getTime()/1000) - tz);
};
if (settings.timeSync && NRF.ctsGetTime) {
if (NRF.ctsIsActive())
NRF.ctsGetTime().then(ctsUpdate, function(){ /* */ })
E.on('CTS',ctsUpdate);
}
}
6 changes: 4 additions & 2 deletions apps/ios/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{

Check failure on line 1 in apps/ios/metadata.json

View workflow job for this annotation

GitHub Actions / build

App ios file settings.js doesn't exist
"id": "ios",
"name": "iOS Integration",
"version": "0.13",
"version": "0.14",
"description": "Display notifications/music/etc from iOS devices",
"icon": "app.png",
"tags": "tool,system,ios,apple,messages,notifications",
Expand All @@ -11,7 +11,9 @@
"storage": [
{"name":"ios.app.js","url":"app.js"},
{"name":"ios.img","url":"app-icon.js","evaluate":true},
{"name":"ios.boot.js","url":"boot.js"}
{"name":"ios.boot.js","url":"boot.js"},
{"name":"ios.settings.js","url":"settings.js"}
],
"data": [{"name":"ios.settings.json"}],
"sortorder": -8
}

0 comments on commit 9c4d905

Please sign in to comment.