Using firebase with WatchKit - ios

I am attempting to use the firebase database in my watchKit app. I have developed this feature on my iPhone application but have found it difficult to do the same on my Watch app. When I attempted to import firebase into the VC class in watch app, it is creating an error no such module 'firebase'.
Is it possible to use firebase inside a watch app?

Sadly there is no Firebase support for watchOS2 and watchOS3 due to the fact that there's no support for CFNetwork in these versions of watchOS and Firebase is highly dependent on this framework. Source (thanks for the link #FrankvanPuffelen in comments).
You have two alternatives:
Use the Firebase REST API directly from your watch app.
Handle all Firebase communication from the iPhone app and use the WatchConnectivity framework to send the relevant changes to your watch app.
Depending on your exact use case, you could choose any of the two. The main advantages/disadvantages of these two are that the WatchConnectivity framework is quite limited as in when it can be used. Both of your apps needs to be running at least in the background for the WatchConenctivity framework to work. On the other hand, if you choose to use the REST API, you don't need the watch app to communicate with the iPhone counterpart, the watch app can directly get the Firebase data using network requests. However, in this scenario, the network usage will be bigger, since you will need to essentially fetch the same information both for the iPhone and watch apps.
Update for watchOS 6:
Firebase Messaging has been released with watchOS support, however, the Realtime Database along with other Firebase SDKs are still not supported. You can track the progress of them in this GitHub issue, which also contains links to the specific feature request issues for the other SDKs.

Firebase v7.9.0 added WatchOS support for realtime database.
https://firebase.google.com/support/release-notes/ios#realtime-database

Related

App tracking transparency iOS 14.5 with newrelic

From iOS 14.5 it is mandatory to use ATT framework if we are sharing user info to the third party or using advertising in the app. Does it require to use of ATT if we are only using newrelic framework in our code.
As the following link points, "if the data is not linked with Third-Party Data for advertising or advertising measurement purposes", you don't need to implement AAT.
Our app was observed by Apple because we were tracking to third-party advertising libraries without implementing AAT. After removing this tracking (we didn't need it anymore) we were able to publish new versions of the app. We don't have issues for tracking to New Relic.

Cordova SQLite Plugin Compatibility

I'm looking to build an iOS hybrid application that also utilizes an Apple Watch application. The watchOS app collects Altimeter data to be stored, and that's it. I was thinking of using this plugin since the watchOS portion is written in Swift. I haven't yet begun the iPhone app, it's just blank right now, but was thinking of making it a hybrid application using Cordova. I've been searching for the best way to share data between the applications, and I think SQLite may be the easiest.
This cordova plugin can be used to manipulate data in an SQLite database using JS. That could be used in the iPhone app. I guess my quesiton is - is this possible? If I create a database in swift using this library, will the Cordova plugin be able to access it? Does anyone have any better ideas for sharing data from a native watchkit app to a hybrid iPhone app?
That will not work. If you create a SQLite database in the watch application running on the watch which is a physically different device than the iPhone running your cordova app, how should the application running on the iPhone access the database?
The way to go to use a watch-kit application in combination with a cordova app is cordova-plugin-apple-watch. The plugin offers three different possibilities to communicate between the watch app and the iphone app:
Message passing
Local notifications and
User defaults
If the data should be accessible by both apps and it should be persistent (like a database) the way to go is probably user defaults. But if you just want to send data from your watch-app to your cordova-app (which will not be needed on the watch anymore) then message passing does also work (the cordova-app can then store the data wherever you want).

Watchkit Connectivity Framework Vs App groups?

I want to share data between watch and iphone application display it in glance view , which is the best way to share data Watch Connectivity framework or app groups ? If Watch Connectivity then which method in Watch connectivity is suitable for transfer data between glance view and iphone application?
App group will work only with a watchOS 1.0 app since the watch kit extension and the main iOS both run on the phone, since watchOS 2.0 the extension runs natively on the watch making app groups useless for data transfer since iOS and watchOS app runs on two different devices.
As Sam B pointed out in the comments since watchOS 2.0 the only way to transfer data between iOS and watchOS is the WatchConnectivity framework. This offers you three way to exchange data, is then up to you to choose the one that best fit your app:
updateApplicationContext:error: transfer a dictionary of data between phone and watch. This dictionary is seen like a state of your app and any new transfer will override previously sent ones, its useful if want to exchange background data. Your data is handled by the operating system and delivered when the receiver wakes up.
sendMessage:replyHandler:errorHandler:/sendMessageData:replyHandler:errorHandler: transfer respectively a dictionary and data (NSData) in real time (the receiver must be running), this is especially useful is game app.
transferUserInfo:/transferFile:metadata: transfer respectively a dictionary and a file in the background like method 1 but all transfers are delivered and not overwritten.
For further information you can read Apple Documentation or watch WWDC 2015 session 713.
About your last question method 2 doesn't fit your needs, maybe more 1 than 3, but that's up to you to decide, after watching the video I linked before you should have more clear ideas about what to choose.
WCSession is best way to communicate with ios application its also support background mode transfer from watch to application and application to watch
Link

WatchOS2 Watch Connectivity still require app groups in capabilities?

In the old WatchOS1, app groups was required for any sharing of data.
In WatchOS2, Watch Connectivity replaces the old framework for communication.
I was wondering if app groups is still needed?
No, app groups will not help with sharing data between your iOS app and the WatchKit extension. You might however need to use an app group between the WatchKit app and the WatchKit extension as some of the media playing APIs seem to run in the app process.

How to establish a communication channel between Apple Watch Extension/App and iOS App

I'm exploring the WatchKit SDK.
When I have a WatchKit app, is it possible to set values (e.g. Text, settings) from the iPhone app on the WatchKit app? Can I call functions in the WatchKit app extension from the iPhone app?
If someone managed to do this, could he/she post an example? Thanks!
You can use App Group and sharedDefaults to share data between the WatchApp/Extension and the App on the phone.
see example:
WatchKit SDK not retrieving data from NSUserDefaults
Study up on iOS8 Extension/App Groups/sharedDefaults and watchkit extension will make more sense.
This sample takes a UIImage from Shinobi chart, save it to defaults as image.
Then extension picks up the image through defaults and shows it on watch
https://github.com/ChrisGrant/ChartWatch
This one uses multipeer connectivity to have watch talk to phone.
https://github.com/jsclayton/swatches
but this uses Bluetooth and I presume the Watch OS also communicates to the phone using bluetooth so not sure if they'll both be allowed.
We have no devices to test on yet so the /swatches app is just watch simuator talking to iphone simulator on same mac.
If youve ever done low level AV programming you know the app may run on the simulator but fail on the device because the simulator can cheat an use Mac OSX media layer. May be the same for bluetooth.
other samples
https://github.com/search?q=WKInterfaceController&type=Code
There are several solutions: CoreData, NSKeyedUnarchiver and NSUserDefaults. With a common background for sharing the common data resource (Database, file or user default settings), this is enabling App Groups capabilities on both targets project properties.
In the following post is explained how to do it with default settings and you can also download the demo project.
With watchOS2 now Apple supports Watch Connectivity Framework to pass information from watch extension to app and vice versa.
Taken from Apple's docs
Communicating with Your Companion iOS App
The Watch Connectivity framework lets you create a bidirectional communications channel between your WatchKit extension and your companion iOS app. Use this channel to coordinate activities between the two processes. For example, you might use this framework to push updated information from your iOS app to your WatchKit extension. The framework provides options for transferring data in the background or while both apps are active and replaces the existing openParentApplication:reply: method of the WKInterfaceController class.
For more information the classes of the Watch Connectivity framework, see Watch Connectivity Framework Reference.
Taken from Apple's Developers Library
You can see this library
https://github.com/mutualmobile/MMWormhole
It do Message passing between iOS apps and extensions.
looks like the links with brain.clear are not pointing to the right destination for ShinobiChart example
https://github.com/ShinobiControls/ChartWatch

Resources