This might be a very short and trivial question, but how do I get information from Xamarin.Android to Xamarin.Forms?
Basically, what I would like to do is the following:
First I retrieve a token in my Android project from the Google Play
Services.
Then I start my main application and show a login screen.
During the login I would like to forward the token to my server, so he is aware of my token and can send me messages.
Is that a good idea? How do I get my token into the Forms part of my application?
Thanks in advance!
There are multiple options for communicating between Xamarin.Forms and the individual platform specific projects.
You can call into Xamarin.Forms from each project rather easily by accessing the Xamarin.Forms.Application class and it's "Current" property which will give you the instance of your Xamarin.Forms application.
You can also do the reverse - call into your specific platform project by utilising the DependencyService class from your shared Xamarin.Forms code. With async/await and TaskCompletionSource this can be a good way to abstract the inherent async nature of obtaining tokens on android/ios into a single awaitable function call.
You can find more information on DependencyService here
Lastly, from what I gather, you are figuring out how to register for push notifications. It might be best to simply use the PushNotifications plugin located here.
It should help you get started. Be sure to read through the documentation. There are a bunch of steps needed to get everything working.
If you have more specific questions or get stuck somewhere, post a new question, I have integrated push notifications on both Android and iOS succesfully before and might be able to help you out.
Related
I am looking a viable approach to record the usage / performance of various parts of a C# desktop application. I see strong parallels with the web focused Real User Monitoring technique and have access to Datadog to process my data.
Is RUM outside the web a viable approach? I believe I will have to implement the equivalent of the JS Datadog SDK if I want to go down this road, is there a way to do this out of the box?
I want to be able to track user usage for certain function calls and capturing exceptions seem sensible.
There are some event model disconnects between the desktop and web but RUM can be used with Android and iPhone apps as well. I implemented this using the json-schema files in the Android SDK and a bit of trial and error on how I wanted to map function calls into the RUM event model.
I'm currently researching on how to mute the windows 10 notification but it i havent found any concrete solution yet.
What i want to do is to disable all notifications when i press a button or check a checkbox.
It is similar on what you do on the notification settings, but i want it to do it progmatically on my application.
I'm currently reading the document of microsoft about Notification Listener.
https://learn.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/notification-listener
NotificationListener allows you to access the notifications, but not to the configuration of the system. And you must think it's a UWP Api...
You want to do something that can not be done in UWP Api(impossible) nor WPF(possible, i wish you good luck).
You can't change system settings inside the UWP app box -safety and things-. The way to do it is "Open the Configuration App where you want the user make the change".
If you wan't to this in WPF/.net you'd have to play with PInvoke and WinApi seriously. And that means thinking about privileges, run as admin, find the functions in WinApi .h files, etc...
Keeping simple, in UWP, nope; in WPF, you have to read a lot of source code/documentation of Windows .h files, make the c# version of the structs, etc...
The real question here is... It's necessary? Windows provides Focus Assist with two clicks (corner, Focus Assist)
I really appreciate your feedbacks! I did some tinkering and found out the service responsible for the notification. I'm not really confident that this is the best approach, but it is working for me.
What I did was I stopped the service using C#. Here is my sample code:
ServiceController[] services = ServiceController.GetServices();
foreach (ServiceController service in services)
{
if (service.ServiceName.Contains(serviceName))
{
service.Start();
}
}
Here is the service responsible for the notifications:
Notification Service
I dont know if this is a good practice or not so I'm still open for feedbacks and suggestions.
Thank you!
I can find the ways to receive and handle shared Text/Data on Xamarin.Android how can the same be done on Xamarin.iOS?
When you share something on WhatsApp I want my app to show up here:
Then I need to handle the data. I really cannot find many answers to this, some say it can't be done using xamarin. Others want to rely on WhatsApp's API. The rest use Swift or Java where I need C#.
Any help would be highly appreciated. Thank you for your time.
This is iOS Share Extension and can be done on Xamarin.iOS
There is a detailed document here for all other iOS Extensions since iOS 8 with a short video. A tutorial for Today Extension but the creation of Share Extension is similar.
https://learn.microsoft.com/en-us/xamarin/ios/platform/extensions
You can look at the Xamarin.iOS sample code for Share extension (which meets your issue: https://developer.xamarin.com/samples/monotouch/ios8/Share/
I am looking to create a videocall app but I am a bit unsure where I should start. Preferably I would like to implement a service like skype or something similiar to avoid creating the entire code myself but maybe that is what i have to do. I have a camera stream already implemented (avfoundation) but i can imagine there is a lot of work left in order to create a fully working videocall code.
What options do you guys think I have? Is it possible to implement skype for xamarin forms? I also saw a component called Twilio that you can use in xamarin forms but it seems like it is not supporting a video call, atleast not the component in xamarin forms.
Any help, tips, links is greatly appreciated!
You could use Azure Media Services for this.
https://azure.microsoft.com/en-us/services/media-services/
I am currently working on a solution where i want to livestream from my app. I succesfully get my camerastream working with avfoundation. The next step in order to complete my task is to send my video frames to a rtmp server but I am not sure on how i can accomplish this in xamarin forms ios.
For swift there is a library called https://github.com/jgh-/VideoCore that solves this but do we have something similiar in xamarin (any library) or documentation on examples that tackles this issue?
Thanks a lot!
Maybe it's a bit late for you, but this can probably help someone who wants to do the same thing (like I did), you can use the Xamarin port of LFLiveKit:
https://github.com/rhedgpeth/Xamarin-LFLiveKit
You'll have to implement a custom renderer to use it with forms, but it's not too hard if you follow the sample project in the repository.