Xamarin Apple Watch Extension - Consuming simple JSON Web Service - xamarin

I've built a simple Xamarin.forms app which connects to a web service and gets one piece of data and displays it.
I wanted to do the same on an apple watch (targetting a series 2 apple watch) but I just don't understand how it works.
I've added the watch project and the watch extension, created the interface... Got a "refresh" button which changes the value of the label to a hard coded value but I want to get the data from a simple web service on app startup on wake and when button is activated (similar to my xamarin.forms iphone app)
I've tried using the classes that I use on the forms app to get the data but I can't reference them. I've tried using httpclient and that doesn't work.
After googling it appears I am suppose to use a HandleWatchKitExtensionRequest delegate in the phone app to get the data in a dictionary and then display the data. I haven't been able to find any really simple examples of this, but I'm confused because since apple watch version 3 the watch has been autonomous with cell access and therefore it doesn't have the host app necessarily.
So what I'm asking, is can the watch actually consume a web service alone using a xamarin phone app and if so, is there any simple examples because I can't find any (that aren't from 2015).
Sorry if this is vague, or I sound like a newbie (I definitely am a newbie when it comes to xamarin but any pointers or help would be appreciated)

According to https://developer.apple.com/documentation/foundation/nsurlsession?language=objc NSURLSession is available since watchOS 2.0. It is used to download the content from the web and is extensively documented just don't search for watchOS specifically as it is the same on all Apple OS.
But as HttpClient uses NSURLSession it is also available, so, maybe you need to add the reference to System.Net.Http.

When I was last developing for the watch I noticed that HttpClient would never work. I had to use NSUrlSession, so this is what helped me.
Hope this Helps

Related

Struggling to find good Examples of iOS app clip & Android instant Apps

I've searched for examples of iOS app clip & Android instant Apps but could not find more than few examples.
I am looking for released apps in App Store/Google Play or open source examples.
good examples could make developing these new features easier and gives developers new creative ideas to use these wonderful tools.
Do you have an app that utilizes App clip or instant app?
How did this affect your app?
What is the challenges you have faced?
Note: I know this is not a typical question but it need to be asked in a community full of great developers who love to share knowledge with others, and I don't think there is a better place than here.
Intro
I know it's been 10 months since you posted the question but I just stumbled upon it now... I've developed an app called ARShades for both iOS and Android that allows the user to try glasses on via Augmented Reality and I'm still in charge of development. The app supports both Instant App and App Clip, although I'm facing troubles making the the app banner show for the App Clip.
Firebase issues
As far as I can tell developing App Clips is a tad harder than develeloping Instant Apps, I'll tell you why. The main apps for both systems make extensive use of Firebase Firestore and many other features. This isn't a problem on Android where sockets are supported across the board, while on iOS they are only supported in the main app, so I had to use REST API to read and write data on Firebase when developing the App Clip, it's been a nightmare since it was the first time for me dealing with REST APIs (I just finished yesterday and published the update).
App Size
Another issue I faced is related to reducing the app size. On Android I had to remove all the unused images and compress the remamining ones. On iOS I had to separate the asset catalogues between: used only by the main app, shared, and used only by app clip. And of course I went through some compression works there too. I forgot to mention that I developed a new app as Instant App on Android, while you cannot do the same on iOS since it must be in the same project.
App to site linking
Another insidious part was the linking of the site to the apps. I managed to do it on Android by making changes to the manifest and specifying the host, while I can't seem to find a way to link the App Clip to the site in ay way. I've done everything the documentation says. I've put the apple app site association file in the .well-known folder but nothing, no banner shows up. I'll keep working on that.
Edit: Everything is now solved.
Conclusions
So, to sum up, I've found Instant Apps better on the developing and hassle side of things, the support sockets, hence the full suite of frameworks the full apps have. I hope I kind of answered your question, although I think you have documented yorself elsewhere in these past 10 months XD
Links to Android: https://play.google.com/store/apps/details?id=it.spaarkly.arshades&hl=en_US&gl=US
Link to iOS: https://apps.apple.com/us/app/arshades-demo/id1586661818
Link for trying Instant App / App Clip

Hybrid apps to Xcode

it's a really normal thing to say "I build Hybrid apps", but why can't I find anywhere on the internet how to achieve this? I read about adding cordova and build ios with that, but that doesn't make it a Xcode project I can open.
I build a Hybrid app with framework7.io with Vue. That's finished almost, but how can I make this a app to submit to Apple now? It's probably a non-framework7 related way around to achieve this. But the internet shows me only some years old tutorials how to do it in Phonegap..
You still need a native "container" project to submit your web-app to the app stores. A native "container" project is a XCode or Android Studio project which contains a webview which renders your web-app (the files a served via the file:// protocol or via a local HTTP server). You can setup one of these yourself or (which I strongly recommend) use a framework for doning the heavy lifting. You can choose the one you like most, some examples:
Cordova
PhoneGap
IntelXDK

Nativescript detect other Apps

Is there a way in Nativescript to detect when another App opens and if so then close it based on a setting flag?
I found a plugin http://plugins.nativescript.org/plugin/nativescript-applist that will list all apps on the phone
NativeScript does not provide such a logic, neither internally nor as a plugin, afaik.
For the Android side you could realize this behavior by writing a background Service which is started at system boot time and periodically checks if apps have been started. Here is an link to an example on SO.
For the iOS side I think this is not possible, imho (correct me if am wrong).

Auto-update with Windows Phone 7 and PhoneGap

I'm thinking of developing a Windows Phone 7 application using PhoneGap and have a few questions around functionality available. I haven't developed a WP7 application before nor used PhoneGap so forgive me if some of the answers to these questions are obvious.
Does PhoneGap support the capability to update HTML/JS/CSS/Images hosted by the WP7 app? I imagine it's possible to easily download new content, but whether one can update or extend the existing files PhoneGap is using for the application is not clear. Given that the application functionality will be primarily driven by HTML/JS, I assume it's possible to download updated HTML/JS asynchronously and update the content on the device. In effect, this would be tantamount to updating the application without downloading a new version of the application through the MarketPlace. Assuming this is possible, what are the chances that an application which does this will pass the application verification process?
Are there any specific restrictions/guidelines that one should pay more attention to when developing an application using PhoneGap? I doubt there are but it would be helpful if anyone has any specific advice in this area.
Any help would be appreciated.
1) The short answer is yes.
The long answer is that you will need to do some native (in this case C#) dev to make that happen. I don't know the specifics of PhoneGap, but I know you can call C# methods from the JS. So you would call a method to download the data and store it in the IsolatedStorage, and then maybe have a callback to the JS to let it know it's done. Otherwise, there may be a way to download the image in JS and pass it to the code behind, but unless the PhoneGap guys have specifically catered for this scenario then I highly highly doubt it.
1.2) Yes, this will pass cert just fine. It is not up to MS to determine how/why/when/where you get your content. They don't make any money out of you updating an app, so they won't care whether you work out your own content delivery system.
2) Maybe not exactly the answer you are looking for - but if you make an app in PhoneGap, or any other non-native way, the app-gods will strike you down. To put it simpler, PhoneGap and everything like it is crap. Not the actual framework (I'm sure they put a lot of work into it), but the results. Seriously, the moment you run a non-native app you can tell how terrible it is. I don't know how to stress this enough. It's really worth developing it natively to every platform.

Best way to approach WP7 app development?

I have some knowledge of basic PHP developing however right now I am thinking about developing a phone app. I do however have a bit of a conundrum in that I love WP7 and I have so many ideas for features which can't be done on iOS and Android, however at the same time I am completely aware that my target users (filmmakers) generally have iOS or android phones.
Is there a way I can develop the app, which I will get a developer to do rather than myself, with WP7 as the lead platform and then make a relatively simple conversion to the other platforms or do apps generally have to be completely reworked for each platform?
Also, just to though it out there, any idea of where to go to find a freelance app developer?
Thanks
James
I think you have a few options, but the first question I would have is: where comes the data from. Are you the owner of the data, and do you already have a datasource from where you can get the data from? If not I would suggest take some time to write a decent 'backend' from which the different platforms easily can get the data from.
Also all different platforms have their own pro/cons which you cannot share that easily. If you build a WP7 app in silverlight/xna, you cannot directly port it to a ios/android variant, also functionality will probably look/react different. You will need different solutions foreach platform with this approach.
Another option would be to use an platform like phonegap which can create a solution that will work on multiple platforms. (It uses HTML5 to get it work on the different platforms)
Build your app on iOS and android first, and when you have an app to base WP7 development then contact a developer that has made similar apps to yours.

Resources