predictive-technology-laboratory / sensus

A Cross-Platform System for Mobile Sensing
http://predictive-technology-laboratory.github.io/sensus
Apache License 2.0
37 stars 39 forks source link

Add push notifications to ping participant phones. #130

Closed MatthewGerber closed 6 years ago

MatthewGerber commented 7 years ago

Related to #329.

MatthewGerber commented 7 years ago

Then create a simple web view that allows us to view the pending notifications for all users in a study. Would be very handy for monitoring and addressing issues (e.g., by contacting subjects with no notifications scheduled).

jtb8vm commented 6 years ago

Xamarin University's tutorial, uses an approach where we would first get a successful notification sent directly from the Notification Hub without worrying about the Azure Mobile App backend. The steps for this approach would be :

MatthewGerber commented 6 years ago

@jtb8vm Yes, the second approach (testing the hub-PNS-device pathway before incorporating back-end) seems like the appropriate place to start.

jtb8vm commented 6 years ago

Cool-- I will work in that direction. I will try to get us as close as possible with the FCM and APNS setup, we still good for 4pm today?

Best, Jordan

On Wed, Feb 14, 2018 at 8:58 PM Matthew Gerber notifications@github.com wrote:

@jtb8vm https://github.com/jtb8vm Yes, the second approach (testing the hub-PNS-device pathway before incorporating back-end) seems like the appropriate place to start.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/predictive-technology-laboratory/sensus/issues/130#issuecomment-365804798, or mute the thread https://github.com/notifications/unsubscribe-auth/AJMgt2UbrO3-_uSSE40zCmW3ylCFfqbaks5tU49WgaJpZM4G92dq .

MatthewGerber commented 6 years ago

Yes, 4pm.

On Thu, Feb 15, 2018 at 11:08 AM, Jordan Buzzell notifications@github.com wrote:

Cool-- I will work in that direction. I will try to get us as close as possible with the FCM and APNS setup, we still good for 4pm today?

Best, Jordan

On Wed, Feb 14, 2018 at 8:58 PM Matthew Gerber notifications@github.com wrote:

@jtb8vm https://github.com/jtb8vm Yes, the second approach (testing the hub-PNS-device pathway before incorporating back-end) seems like the appropriate place to start.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/predictive-technology-laboratory/sensus/issues/130# issuecomment-365804798, or mute the thread https://github.com/notifications/unsubscribe-auth/AJMgt2UbrO3-_ uSSE40zCmW3ylCFfqbaks5tU49WgaJpZM4G92dq .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/predictive-technology-laboratory/sensus/issues/130#issuecomment-365975239, or mute the thread https://github.com/notifications/unsubscribe-auth/AEbY-iFhwLSaqptBqgNq91EasXuYD0k9ks5tVFaHgaJpZM4G92dq .

jtb8vm commented 6 years ago

Firebase Cloud Messaging (FCM) Android notification setup.

First Steps:

Next Steps:

jtb8vm commented 6 years ago

Baseline implementation is committed. We register the device with FCM in FirebaseIIDService.cs, then handle incoming/outgoing messages in FirebaseMessagingService.cs. I was able to send / receive data and log it to the application output:

image

The token is generated by the Firebase IID Service (in this case my emulator). Then, the Firebase Messaging Service prints out the payload:

image

There is also a warning about a missing analytics library. This makes sense, as in the FCM console I can't see whether or not the message went through. For next steps I will add these analytics, and then we can move onto triggering events.

MatthewGerber commented 6 years ago

Excellent. Is this going from FCM->device or Azure->FCM->device?

jtb8vm commented 6 years ago

Hi Prof. G,

For now it's just FCM->device, but to get Azure involved we just need to put the notification into JSON-form. I'll take a look at that today! I also want to make sure the Firebase Analytics are working, I haven't been able to see any results in the FCM console. Then after that we can discuss event triggering?

Best, Jordan

On Mon, Feb 19, 2018 at 9:03 PM, Matthew Gerber notifications@github.com wrote:

Excellent. Is this going from FCM->device or Azure->FCM->device?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/predictive-technology-laboratory/sensus/issues/130#issuecomment-366846521, or mute the thread https://github.com/notifications/unsubscribe-auth/AJMgt1HikuqKKY76wCbLNSdEZe2WJ2SVks5tWifngaJpZM4G92dq .

MatthewGerber commented 6 years ago

Sounds good.

On Tue, Feb 20, 2018 at 9:01 AM, Jordan Buzzell notifications@github.com wrote:

Hi Prof. G,

For now it's just FCM->device, but to get Azure involved we just need to put the notification into JSON-form. I'll take a look at that today! I also want to make sure the Firebase Analytics are working, I haven't been able to see any results in the FCM console. Then after that we can discuss event triggering?

Best, Jordan

On Mon, Feb 19, 2018 at 9:03 PM, Matthew Gerber notifications@github.com wrote:

Excellent. Is this going from FCM->device or Azure->FCM->device?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/predictive-technology-laboratory/sensus/issues/130# issuecomment-366846521, or mute the thread https://github.com/notifications/unsubscribe-auth/ AJMgt1HikuqKKY76wCbLNSdEZe2WJ2SVks5tWifngaJpZM4G92dq

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/predictive-technology-laboratory/sensus/issues/130#issuecomment-366985916, or mute the thread https://github.com/notifications/unsubscribe-auth/AEbY-oP-Cr2fvYCzWEJGOY4CfjsZG4Ecks5tWtAogaJpZM4G92dq .

jtb8vm commented 6 years ago

Just got a successful 201 Message Sent using the Notification Hub REST API:

image

I was able to follow this documentation about directly sending notifications to a device by id. You can also send batch notifications. The steps are simply: generate SAS token, format the POST request, and send. In this example, I used Postman to send a notification and was able to receive it locally for my android emulator. I followed this to generate a SAS for use with notification hubs.

More setup documentation here.

MatthewGerber commented 6 years ago

Great. Looks like we're getting close to integration. Let's meet soon to discuss integration.

On Fri, Feb 23, 2018 at 3:26 PM, Jordan Buzzell notifications@github.com wrote:

Just got a successful 201 Message Sent using the Notification Hub REST API:

[image: image] https://user-images.githubusercontent.com/9642167/36614547-1505e58e-18ab-11e8-8ba6-8c581d32c95a.png

I was able to follow this documentation https://msdn.microsoft.com/en-us/library/azure/mt608572.aspx about directly sending notifications to a device by id. You can also send batch https://msdn.microsoft.com/en-us/library/azure/mt734910.aspx notifications. The steps are simply: generate SAS token, format the POST request, and send. In this example, I used Postman to send a notification and was able to receive it locally for my android emulator. I followed this https://docs.microsoft.com/en-us/rest/api/eventhub/generate-sas-token to generate a SAS for use with notification hubs.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/predictive-technology-laboratory/sensus/issues/130#issuecomment-368129313, or mute the thread https://github.com/notifications/unsubscribe-auth/AEbY-tu3_IxPz_f8_BDl-oZm71S-ZgS7ks5tXx8IgaJpZM4G92dq .

jtb8vm commented 6 years ago

Moving forward with integration, setup steps are documented here.