From 800ed1be80e7e9726272ddba0e3cc571c69f6134 Mon Sep 17 00:00:00 2001 From: Ankur Nigam Date: Thu, 11 Apr 2019 21:53:31 +0530 Subject: [PATCH] tt --- MotionDetectionSurvilance/MainPage.xaml | 4 ++-- .../MotionDetectionSurvilance.csproj | 4 ++-- MotionDetectionSurvilance/Package.appxmanifest | 2 +- MotionDetectionSurvilance/Web/NetworkManager.cs | 2 +- .../Web/SubscribeNotificationData.cs | 7 ++++--- README.md | 14 ++++++++++++++ docs/sw.js | 5 ++++- 7 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 README.md diff --git a/MotionDetectionSurvilance/MainPage.xaml b/MotionDetectionSurvilance/MainPage.xaml index 72c0906..3baf660 100644 --- a/MotionDetectionSurvilance/MainPage.xaml +++ b/MotionDetectionSurvilance/MainPage.xaml @@ -24,8 +24,8 @@ -

Preview Stopped

"; } - private async Task SendImage() + public static async Task SendImage() { try { diff --git a/MotionDetectionSurvilance/Web/SubscribeNotificationData.cs b/MotionDetectionSurvilance/Web/SubscribeNotificationData.cs index e09fb64..3359b2a 100644 --- a/MotionDetectionSurvilance/Web/SubscribeNotificationData.cs +++ b/MotionDetectionSurvilance/Web/SubscribeNotificationData.cs @@ -16,7 +16,7 @@ class SubscribeNotificationData public string p256dh { get; set; } public string auth { get; set; } - public void SendNotification() + public async void SendNotificationAsync() { var pushEndpoint = endpoint; var p256dh = this.p256dh; @@ -34,7 +34,8 @@ public void SendNotification() try { //webPushClient.SendNotification(subscription); - webPushClient.SendNotification(subscription, "haww koi hila", vapidDetails); + var payload = new { message = "Haww koi hila", image = await NetworkManager.SendImage() }; + webPushClient.SendNotification(subscription, JsonConvert.SerializeObject(payload), vapidDetails); //webPushClient.SendNotification(subscription, "payload", gcmAPIKey); } catch (WebPushException exception) @@ -65,7 +66,7 @@ public static void sendNotificationToAll() var tf = new TaskFactory(); foreach (var item in listSubs) { - await tf.StartNew(() => item.SendNotification()); + await tf.StartNew(() => item.SendNotificationAsync()); } }); t.Start(); diff --git a/README.md b/README.md new file mode 100644 index 0000000..77341bd --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Motion Detection Surveillance + +## System Requirements + +- Win 10 1809 and above +- Camera +- x86/x64/ARM arch + +# Setup + +### **Pre Compiled** (x86/x64 build only) + +- Download latest release from [release](https://github.com/ankur198/MotionDetectionSurvilance/releases) (x86/x64 build only) +- \ No newline at end of file diff --git a/docs/sw.js b/docs/sw.js index 69fbd01..a663e2a 100644 --- a/docs/sw.js +++ b/docs/sw.js @@ -46,11 +46,14 @@ self.addEventListener('push', function (event) { console.log('[Service Worker] Push Received.'); console.log(`[Service Worker] Push had this data: "${event.data.text()}"`); + data = JSON.parse(event.data.text()); + const title = 'Motion detection surveillance'; const options = { body: `${event.data.text()}`, icon: 'https://ankur198.github.io/MotionDetectionSurvilance/images/icon.png', - badge: 'https://ankur198.github.io/MotionDetectionSurvilance/images/badge.png' + badge: 'https://ankur198.github.io/MotionDetectionSurvilance/images/badge.png', + image: 'data:image/png;base64,'+data.image }; event.waitUntil(self.registration.showNotification(title, options));