Can you get realtime data from an Apple Watch workout? - watchkit

Is there a possibility in watchOS 1 or watchOS 2 where you can get real-time data of the built-in Workout app, or would I need to create my own workout app to do so?
In case I made my own app, would I still be able to store the workout in the Activity app, as the built-in one does?

Pretty old question but nevertheless...
You would need to create your own WatchKit app to start the workout and to send messages from the Watches HealthKit database.
You would have to create a StreamingQuery on the Watch and send messages to the companion app on the iPhone with data.
Alternately you could simply query the iPhone HealthKit database but there might be a big timely while the data sync's from the Watch to the phone.
And yes you would be able to create and store your own Workouts in HealthKit

Related

Can I use FCM’s onMessage functions to create a live-chat application?

I’m making an app using react with firebase, and a large part of my app involves group communication. Currently I have FCM sending notifications to people within the group whenever someone types a message into chat. Can I use onMessage to load messages in real time for all group members to see, without needing to refresh the page, or do I need to set up firebase real time database ?
Any help/advice is greatly appreciated !
I would recommend to store the messages in one of the Firebase databases. For multiple reasons. You can only send FCM messages from the backend so you need a trigger for that. Idealy when a new messages is added to the database. If all users for a group listen to messages in a group chat they would see them when you setup a realtime listener. This would work much faster and more reliable than using FCM for realtime data. FCM is idealy used to notify users when they are outside of the app or inside the app but not in the chat by using onMessage. The UI should rely only the databse data and not FCM.

How do you access OneSignal's database on Android & iOS in Flutter?

I am using OneSignal in my Flutter application to receive notifications. I have created my own table within Flutter to save notifications but I cannot save messages that have been sent whilst the app has been terminated. However, I have found that the OneSignal package has it's own database installed on the device which captures everything no matter what state the application is in! So, to avoid duplicating data I want to use this database instead. It is located outside of the flutter app folder which is my issue (see image below).
How do I access this database? Does anybody know if it is the same on iOS (I haven't been able to check at this time).
Many thanks.
It's important to understand that if an app has been terminated, any onReceived handler will not be fired. We don't recommend using the local db at all. Your best bet is to use the respective notification extender services for each platform. Though you will have to write native code for this! Cheers
Edit:
ANDROID - NotificationExtenderService - This can be setup to receive silent notifications when your app is not running or to override how notifications are shown in the notification shade. See the Background Data and Notification Overriding section to set this up.

How to move old chat data from Firebase database to another database

We are developing a chat app for Android and iOS which uses a Firebase database for storing chat messages. We don't want keep all chat messages in Firebase database because storage gets bigger and expensive everyday. So we want to move 2 days old chat data to another database. Our purpose is to load new messages from Firebase storage and to load 2 days and older messages from another database when user wants to see older messages by scrolling up or pressing "load more" button.
Our database is like this:
Chat Room KEY
Message Id
Message
Time and Date
Reciever Id
Sender Id
I have a few questions.
Can we automatically move older messages to another database based on message created date to decrease database storage costs? What is the best method for this? Do we need to use Firebase Functions?
Do we need to implement auth for our new database so that it know if our user wants to see data? Or is is it possible to query old message data from client side without authorizing our app users. Will it have security problems?
Which database we should use? How would you solve this problem?
Thank you.

What is the best way to use firebase as an events broker?

I am writing a connected home device (alarm system) which can receive events/messages from a mobile device (e.g. a message to dismiss an alarm).
Example of a scenario (mobile device is an iphone for the sake of the example):
Connected device at home sounds alarm and notifies the iphone (using iOS push notifications, not firebase)
iphone user brings up the app, and clicks "dismiss"
connected device gets "dismiss" message and stops the alarm
I was thinking about using firebase's live database for this interaction, so the iphone app would set a db field, and the home device (which runs python) would subscribe to this field and see that it has been set.
The problem is that this is not a very clean implementation, as I would need the home device to turn off the dismiss field after it has received it, so that subsequent dismiss event can be recognized.
Essentially I am implementing messaging on top of a live database.
Is there a cleaner way to do this in firebase?
If not, is this a reasonable implementation?
Are there alternatives to firebase that take care of such a scenario?
What I really need is a web-based event-broker as-a-service...
I would suggest looking at https://github.com/firebase/firebase-queue
There are a few examples of usage on SO such as My Firebase Queue doesn't do anything after I changed to Firebase 3
Many of our developers are using Firebase with a server to perform tasks like background processing, integrating with third party APIs, or handling advanced authentication requirements. Today, we're introducing Firebase Queue, a fault-tolerant multi-worker job pipeline built on Firebase.
If you're writing your server code in Node, Firebase Queue makes it easy to handle background jobs with a worker queue. We're already using it in our private backups feature, where we reliably handle hundreds of jobs per day across multiple machines. ( https://firebase.googleblog.com/2015/05/introducing-firebase-queue_97.html )

How to trigger azure mobile service sync on other clients?

I have a xamarin forms project that uses an azure mobile service with offline sync. The iOS client is working perfectly in that it can save things locally and sync in the background. The context of my app is a game scorekeeper. So, there are two players involved both scoring on the single device.
What I would like to happen is for the "visiting" player or the player who doesn't own the device in use (ie not the primary user) to have their device sync when new data is pushed from the device in use.
Device A pushes new content, Device B somehow knows to pull new content.
This could open the door for each player to score on their own devices in a future version.
Anyway, the question is how do I tell device B to pull? Do I use APN type notification and that triggers a sync, or SignalR to tell it to sync?
The best approach on sync scenarios like this is to have your background sync process going at set intervals but then also trigger your sync process from a specific Push Notification.
If you send a Push Notification with a "special" payload (i.e. meaning something that just means to sync to your code). Then start the sync once the device receives that.
This article might help with Azure Push Notifications with Xamarin Forms: http://www.xamarinhelp.com/push-notifications/

Resources