How to create a Cron Job in a Xamarin.Forms app? - c#

I've created a Cron Job in my API using IHostedService and the Cronos nuget package however I'm trying to do the same in my Xamarin.Forms app but it doesn't seem to work.
I've read that both Android and iOS have their own version of it with for example the Android Job Scheduler but I really want it to be an actual Cron Job and for it to work just like it does in my API.
Is there a way to do it this way ?
The tutorial I've followed is this one:
https://codeburst.io/schedule-cron-jobs-using-hostedservice-in-asp-net-core-e17c47ba06
Thank you so much.

You cannot achieve this directly in Xamarin.Forms
You need to use WorkManager or a background service in Xamarin.Android
https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/services/
For iOS, you would have to follow this guide.
https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/
Update:
More powerful background tasks are now possible in iOS
https://developer.apple.com/documentation/backgroundtasks
C# bindings for the classes you see on the link are available. You have to follow the above documentation. Although it might be in Swift/Objective-C, the class names and methods would be similar.

Related

How to use CoreNFC in xamarin.forms?

I'm totally new in xamarin.
I'm trying to use CoreNFC in my xamarin.forms multiplatform app.
But I don't know how to do it because i can only import CoreNfc in myapp.ios and not in myapp.
There is someone that know how to do it ?
Thanks in advance!
Core NFC belongs to the iOS Framework, so you can import and use it only in our iOS Project.
You could implement the NFC feature on each platform you want to support and use a interface and the Xamarin Dependency Service, to have access to these platform specific implementations in your shared code.
Or you look around for a plugin which did this work for you. A starting point could be NFCForms from poz1. But if I remember well it has so far only support for Android and Windows Phone.

Compiling C# Code in UWP

I have using the built in CSharpCodeProvider class in previous C# .NET projects and it has worked great. I see this has been removed in UWP. I've been banging my head against the wall trying to figure out if there is a way. I can't seem to find any scrap of information. But, I did come across an interesting app called #Code by Shahul Hameed on the Windows Store. This software claims to be able to compile code and be able to run it, and indeed it does. How are they achieving this, if such actions are not possible on the framework? Is it possible they're sending the code over the net to a web service of some kind and getting the returned console output? I thought so, but what about the live stdin support they've provided in the app, how would that work in a cloud compile situation?
Thanks for shedding any light
Code on Windows Store: https://www.microsoft.com/en-us/store/p/code/9nblggh4s3mf

background task and SQLite in windows Universal 8.1

I created a project of Windows Universal app. Then I add a new Runtime Component (background task C#) for update my tile.
Then I install sqlite-net for background task. I want to read some data from my database.
When I want to run my app, I get some error from SQLite.cs.
http://borjianamin.persiangig.com/errors.png
I search a little and I found this Topic: (I'm sorry for this because I don't have enough reputation)
stackoverflow.com/questions/14812076/how-to-connect-to-sqlite-database-from-windows-runtime-component-which-is-for-ru
github.com/praeclarum/sqlite-net/issues/104
I use replace tool of VS2015 and replace all public with internal But I get about 300 errors this time.
This is my background task project only:
Link: http://www.rodfile.com/uu9viaaxsz91
Is it possible to help me?
Thanks.
Yes it is possible. You have to add a separate project for SQLite called Class Library.
Then you have to add sqlite.net in that class library. After that you need to add the reference of Class Library on Windows Runtime Component.

Dynamic IVR menu application in MVC using twilio API

I am trying to develop an application in MVC4 where client can configure Dynamic menu for Incoming Calls from user Interface using Twilio API. Is there any opensource project exist or any voice model for dynamic IVR menu from where i can get an idea and application flow for GUI design. Your help in this regard will be highly appreciated.
Twilio developer evangelist here.
To my knowledge there isn't a .Net project that demonstrates how to build an IVR using Twilio. however, there are a few tutorials showing how to do it, and because most of it uses TwiMl, you should just be able to generate that using the libraries, or by simply making your requests return such verbs when necessary.
I would definitely stat off by looking at the following:
Project: Build a Simple IVR The example is in PHP, but you should very easily be able to translate that into C#
IVR: The Basics A good resource that tells you how IVR's actually work
Build an IVR system with Twilio and Django Another tutorial showing how to build an IVR using Django
With the URLs above you should be ale to get your IVR up and running in no time, but by all means feel free to reach out to me if you need any help. I'm a C# developer myself, so will be able to assist you if you get stuck with anything.

Build portable SignalR component with Xamarin

I have a Windows Phone 8 app that makes use of real time server push via SignalR.
I started to create a Native Android and iOS version of my app, but got stuck at implementing my SignalR component in native Android Java and iOS obj-C.
I have conceptually thought of a way to achieve this by making ONLY JUST the SignalR component portable via Xamarin.
Is it possible to create a Hybrid app in this way ?
And are there any resources online where people have done such.
Thanks for your help.
Xamarin would be kind of an all in sort of thing. So all of your Objective-C and JAVA would need to be ported to Xamarin's framework. That might not be a bad idea though ;).
Alternatively, if you are looking for a more cross platform way to implement a SignalR client, you maybe could wrap the logic up in a UIWebView (iOS) or WebView (Android) and use the JavaScript components. Here is an example from Microsoft on implementing a SignalR client via JavaScript. I don't know how integrated the SignalR functionality is in your app, but this may be an easy way to use it for simple display purposes.

Categories

Resources