From a567016172b678e6e2a7638b8e74be9bb853f291 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 15 Dec 2022 09:19:10 +0000 Subject: [PATCH] iOS Making ANCS message receive more resilient (#2402) --- apps/ios/ChangeLog | 1 + apps/ios/boot.js | 12 ++++++++++-- apps/ios/metadata.json | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/ios/ChangeLog b/apps/ios/ChangeLog index 5763801f5..8ab99b4db 100644 --- a/apps/ios/ChangeLog +++ b/apps/ios/ChangeLog @@ -10,3 +10,4 @@ 0.10: Added more bundleIds 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) diff --git a/apps/ios/boot.js b/apps/ios/boot.js index ee19ca14b..8952a047e 100644 --- a/apps/ios/boot.js +++ b/apps/ios/boot.js @@ -26,7 +26,7 @@ E.on('ANCS',msg=>{ // not a remove - we need to get the message info first function ancsHandler() { var msg = Bangle.ancsMessageQueue[0]; - NRF.ancsGetNotificationInfo( msg.uid ).then( info => { + NRF.ancsGetNotificationInfo( msg.uid ).then( info => { // success if(msg.preExisting === true){ info.new = false; @@ -38,6 +38,10 @@ E.on('ANCS',msg=>{ Bangle.ancsMessageQueue.shift(); if (Bangle.ancsMessageQueue.length) ancsHandler(); + }, err=>{ // failure + console.log("ancsGetNotificationInfo failed",err); + if (Bangle.ancsMessageQueue.length) + ancsHandler(); }); } Bangle.ancsMessageQueue.push(msg); @@ -196,7 +200,11 @@ Bangle.messageResponse = (msg,response) => { // error/warn here? }; // remove all messages on disconnect -NRF.on("disconnect", () => require("messages").clearAll()); +NRF.on("disconnect", () => { + require("messages").clearAll(); + // Remove any messages from the ANCS queue + Bangle.ancsMessageQueue = []; +}); /* // For testing... diff --git a/apps/ios/metadata.json b/apps/ios/metadata.json index 5042ff1c0..42e0060d0 100644 --- a/apps/ios/metadata.json +++ b/apps/ios/metadata.json @@ -1,7 +1,7 @@ { "id": "ios", "name": "iOS Integration", - "version": "0.12", + "version": "0.13", "description": "Display notifications/music/etc from iOS devices", "icon": "app.png", "tags": "tool,system,ios,apple,messages,notifications",