Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

App crash when denied location permission in Xamarin iOS

$
0
0

i need to have location in my app and app got crash when user denied the location permission by clicking "Don't Allow". i got "System.Reflection.TargetInvocationException". but once i again start again even on that time the permission is denied its not crashing . in android its working fine .Do i need to update permission plugin or change in info.Plist? i gave all three permission in info.Plist for Location . here is my code .

  var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);
        if (status != PermissionStatus.Granted)
        {
            if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
            {
                await Application.Current.MainPage.DisplayAlert("Location denied", "app needs access to location for this operation.", "OK");
            }

            var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location);
            status = results[Permission.Location];
        }
        if (status == PermissionStatus.Granted)
        {
              // do something
        }
        else if (status != PermissionStatus.Unknown)
        {
              // Crash when user denied permission 
        }

Best Chat Server for xamarin forms app

$
0
0

Please suggest a best chat server for xamarin forms app with firebase databse integration

How to identify and reference to the dependent Assembly or Library among Projects? resolve Error CS0

$
0
0

How to identify and reference to the dependent Assembly or Library among Projects? resolve Error CS0012?

Error:

Error CS0012
The type 'IAsyncOperation<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.FoundationContract, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.
ViewModels

My UWP app-solution has three projects:

Project-1 (UWP):
Target version: Windows 10 Anniversay Edition (10.0; build 14393)
Min version: Windows 10 Anniversay Edition (10.0; build 14393)
References:
Analyzers
HockeySDK.UWP
Microsoft.NETCore.UniversalWindowsPlatform
PcscSdk
Serilog
Serilog.Sinks.RollingFileAlternate.MultiPlatform
System.Reactive
UniversalWindows
Xam.Plugin.Battery
Xam.Plugin.PopupMenu
Xam.Plugins.Settings
Xamarin.Forms
Dependencies: Projects\ViewModel

Project-2 (Forms):
Target framework: .NET Standard 1.4
Dependencies: NuGet\
Xam.Plugin.Battery (3.0.1)
Xam.Plugin.PopupMenu (1.1.0)
Xam.Plugins.Settings (3.1.1)
Xamarin.Controls.SignaturePad.Form (2.2.0)
Xamarin.Forms (2.5.0.122203)
Dependencies: Projects\ViewModel
Dependencies: SDK\NETStandard.Library(2.0.1)

Project-2 (ViewModel):
Target framework: .NET Standard 1.4
Dependencies: Assemblies\ Windows.Foundation.UniversalApiContract
Dependencies: NuGet\
System.Reactive (3.1.1)
Xam.Plugin.Battery (3.0.1)
Xam.Plugins.Settings (3.1.1)
Xamarin.Forms (2.5.0.122203)
Dependencies: SDK\NETStandard.Library(2.0.1)

Xamarin libraries to generate gif programmatically

$
0
0

Dear Forum

I am building a mobile app using Xamarin for an accident detection system, and i want to be able to achieve the below:

I want to be able to create a GIF using elements such as direction of vehicle, user input of speed of vehicle, angle of vehicle , etc to animate the collision between two cars. Thus i want to be able to Animate car A to move towards Car B using the elements i mentioned and then on supplying the parameters, a GIF can be generated showing the collision between two cars

Please are there any libraries that can help me generate a GIF programmatically without having to provide images of the accident etc...

How to implement Firebase In-App Messaging

$
0
0

Hi guys,
I want to add Firebase in-app messaging in my Xamarin.Droid project how can I do this.
Which nuget can I use for this.
I already have implementing firebase other services.
So I just want to understand the client part.

Unable to bind a ContextAction menuItem command to the viewModel.

$
0
0

I have a ListView with Textcells and have added TextCell.ContextActions with MenuItems. I have a Delete Menu item and bounf the command to a command in my view model which is hooked up to a method. However, the method is not being hit. Any ideas?

<ListView x:Name="lvNotes" ItemsSource="{Binding Notes}" IsVisible="{Binding PersonNotesVisible}" RowHeight="70"> <ListView.ItemTemplate> <DataTemplate> <TextCell Text="{Binding Title}" Detail="{Binding DateAdded}"> <TextCell.ContextActions> <MenuItem Text="Share"/> <MenuItem Command="{Binding DeleteNoteCommand}" CommandParameter="{Binding .}" Text="Delete" IsDestructive="True" /> </TextCell.ContextActions> </TextCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

In the VIEWMODEL, I have initiated the DeleteNoteCommand in the VM constructor

public ICommand DeleteNoteCommand { get; set; }
DeleteNoteCommand = new Command(DeleteAction);

    private void DeleteAction(object obj)
        {

        }

How to interact with local Database file outside app storage?

$
0
0

Hi!
I want to interact with local Database file (SQL, SQLite, MS Access, etc.) is store outside of app (SD Card, A PC on LAN).
Please show me how to do this!
Thank you!

XF image tapgesturerecognizer not working on UWP?

$
0
0

xamarin forms image tapgesturerecognizer not working on UWP, working fine on Android. How to fix it? Thank you!


Is the Geofence API limited to push notifications? Or can it ping my server via REST API, while in t

$
0
0

I'm in the process of designing a mobile Xamarin app and would like to know if both iOS and Android devices can monitor GPS in the background for geofence entry/exit, and then ping my web servers via REST API.

The app will be run in the background by truck drivers, and their dispatcher will receive a notification on their web-based dashboard when the truck driver enters a particular geofence.

I am looking at the CrossGeeks API as of now, but have no preference which one to use.

All of the samples I've found online send push notifications OnEntry or OnExit. None have examples or mentions of sending updates to a server.

My question is: Can I use the GeoFencing API to wake up my app that's running in the background and send a notification to my server that it's entered a particular geofence?

Thanks in advance.

Is the GeoFence API limited to push notifications? Or can it ping my server via REST API, while in t

$
0
0

I'm in the process of designing a mobile Xamarin app and would like to know if both iOS and Android devices can monitor GPS in the background for geofence entry/exit, and then ping my web servers via REST API.

The app will be run in the background by truck drivers, and their dispatcher will receive a notification on their web-based dashboard when the truck driver enters a particular geofence.

I am looking at the CrossGeeks API as of now, but have no preference which one to use.

All of the samples I've found online send push notifications OnEntry or OnExit. None have examples or mentions of sending updates to a server.

My question is: Can I use the GeoFencing API to wake up my app that's running in the background and send a notification to my server that it's entered a particular geofence?

Thanks in advance.

Resource Dictionary for UWP/macOS and fonts

$
0
0

Hi guys,
I want to use a custom font for my app. I copied the font files in:

  • iOS: under Resources - Build Action BundleResource / Copy to Output Directory: Do not copy
  • Android: under Assets - Build Action Androd Asset / Copy to Output Directory: Do not copy
  • UWP: under Assets/Fonts - Build Action Content / Copy to Output Directory: Do not copy

I have two problems here. First is the UWP error:

Position 11:25. No property, bindable property, or event found for 'UWP', or mismatching type between value and property

The second is how to show my custom font.

Visual Studio 2017

My Xamarin.Forms version is 3.4.0.1029999

Get user's current location from map

$
0
0
Hi devs, I'm kinda new to xamarin and I'm having difficulties getting user's current location from map. Pls how do I go about this? I really need your contribution.

Statically registering a Broadcast Receiver - A working example

$
0
0

Hello there

I wan't to statically register a Broadcast Receiver and I have followed the guidelines at
https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/broadcast-receivers

As I understand we do not register the Broadcast Receiver directly in the Android Manifest file, but instead we decorate our receiver as following

[BroadcastReceiver(Enabled = true)]
[IntentFilter(new[] { "com.xamarin.example.TEST" })]
public class MySampleBroadcastReceiver : BroadcastReceiver
{
    public override void OnReceive(Context context, Intent intent)
    {
        Console.WriteLine("Hurray it works"!);
    }
}

Then the receiver should be able to pick up on the following broadcast

Intent message = new Intent("com.xamarin.example.TEST");
SendBroadcast(message);

However I do not receive this intent. I only receive the intent, when I register the receiver within the context as following

RegisterReceiver(new MySampleBroadcastReceiver(), new IntentFilter("com.xamarin.example.TEST"));

Have I misunderstood something or am I missing some steps? Any help would be appreciated.

Why do I need this?
My goal is to launch notifications at particular timestamps defined by the user. I've context-registered a broadcast receiver, that issues a notification, when an intent is received. The Android Alarm Manager is used to broadcast the intent at a particular time.
As the broadcast receiver is context-registered it will not receive intents, when the app has been killed (when the app is swiped in the recent applications menu). I want the notifications to keep coming when the app has been swiped.

ContextAction Command from custom ViewCell

$
0
0

I have a custom ViewCell which gets selected by a Tempalte Selector.
Now i want that the Command from the ContextAction is executed in the corresponding page ViewModel,
but i don't now how to get the reference to MyPageName.

This is my custom ViewCell:

<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
          xmlns:local="clr-namespace:MyApplication.Converters;assembly=MyApplication"
             x:Class="MyApplication.Pages.Custom.CustomCell">
    <ViewCell.ContextActions>
                                <MenuItem 
                                    Command="{Binding Path=BindingContext.OnSettingsCommand, Source={x:Reference Name=MyPageName}}"
                                    CommandParameter="{Binding .}"
                                    Icon="settings_white.png"
                                    Text="More"/>
                                <MenuItem 
                                    Command="{Binding Path=BindingContext.OnDeleteCommand, Source={x:Reference Name=MyPageName}}" 
                                    CommandParameter="{Binding .}"
                                    Icon="delete.png"
                                    IsDestructive="True"
                                    Text="Delete"/>
                            </ViewCell.ContextActions>
    <ViewCell.View>
        <StackLayout 
                                Orientation="Horizontal" 
                                Padding="10"
                                Spacing="10">
            <StackLayout.Resources>
                <ResourceDictionary>
                    <local:DateConverter x:Key="dateConverter"/>
                </ResourceDictionary>
            </StackLayout.Resources>
            <Image Source="{Binding Image}" />
            <StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand"
                                             VerticalOptions="Center">
                <Label 
                                            Text="{Binding Title}"  
                                            TextColor="{StaticResource Dark}"
                                            VerticalOptions="End"
                                            Font="Medium, Bold"/>

                <Label 
                                            Text="{Binding CreationDate, Converter={StaticResource dateConverter}}"  
                                            TextColor="{StaticResource grayDark}" 
                                            FontSize="Small" />
            </StackLayout>
            <StackLayout Orientation="Vertical" VerticalOptions="Center">
                <Image Source="{Binding ImageConnectionTypeStatus}"/>
                <Image Source="{Binding ImageSignalStrength}"/>
            </StackLayout>
            <Image Source="arrow_right.png"/>
        </StackLayout>
    </ViewCell.View>
</ViewCell>

Does anybody have an idea ?

How to use Windows like filesystem action on Mac?

$
0
0

Hello,

Here is my issue: I have an application using an old mono version (4.4.1) on an old ide (Xamarin 6.0.1) and some Windows internal calls such as FindNext or GetFileStats. These are InternalCall methods that I need to run my application.

I have updated everything to their last version, so I am now using Visual Studio for Mac 2017 and Mono 5.18.0.249 (with their associated XamMac.dll).
When I start the application, it says that FindNext or FindFirst method is not found anymore (Missing method exception) and that my mono build is sort of broken.

So how do I replace these methods?
I need methods that give me the stats of a file (if it's hidden, etc), ones that get the next file in line in a ptr, or the first in a folder, etc.
Such as found on Windows .Net.

If anyone knows I am all ears :smile:

If I was not clear, tell me, I will try to explain the situation better.


Windows 10 entreprise, Visual studio 2017 Pro(15.9.6)+ Xamarin UITest

$
0
0

Hello, I am using visual studio 2017 Pro(15.9.6) with Xamarin .UITest (2.2.4), NUnit 2.6.4, NunitAdapter (2.1.1)- As virtual Android, I am using Genymotion Google Nexus 6(api 25). Visual studio 2017 find Genymotion without any problems.
Xamarin.UITest created by default the project TestApp. TestApp can connect to my Android Virutal Genymotion, and start automatically TestApp(no problem for now). I then created some UnitTests, that are in Tests.cs in another project, as explained in the manual of Xamarin.
Now my problem is that when I try to RUN my unitTest via Test Explorer, there is no connection to my Genymotion Android(as well i tried different Android simulators from VS) and get always error: No devices connected.
I also tried to run my Unitest, using the RUN function from VS, but it stop as MainActivity.cs, meaning the TestApp happear on my virtual android, and nothing go forward. I can see that my unitTests are totally ignored.

1 year ago, I had already the same setup and all was working. I think was Visual studio 2015, if i can remember correctly.

Enjoying Xamarin :)

$
0
0

Not a discussion or question per-se but after a wobbly start I'm really enjoying using Xamarin Forms. I just wanted to make a point of saying to others considering using Xamarin (in my case Forms) to give it a go.

I read a lot of bad things about it when researching beforehand, I'm not sure if those things are valid or not as I don't have years under my belt or a project of a larger size but as a newcomer its working out well so far.

How to set value to customstepper

$
0
0

I have a list with a custom stepper in it, and I have a detail page for every item in this list, I need to change the value of the custom stepper when I change it in the detail page and also when I refresh the list.

This is the list of items and the info button is to go to the item detail page

And here is the item detail page

How can I change it? thanks in advance

Reproduce carousel view behaviour/animation/transition to a horizontal scroll view.

$
0
0

Hey developers,
I have so far tried to use a carousel view due to its ease of use and of course its performance. But I tried to show the tail of each UI elements (let's say we've a bunch of cards) whatever the position is as shown in the picture. I've googled a lot and posted another question in this forum but since then I changed the project UI a little bit so I ignored the given solution and now I am on my own again, I resolved it (show the next card's tail or/and the previous), I'll write down the structure I used in XAML but first let me highlight my requirements.
I want to reproduce the behaviour, animation/transition on swiping of the carousel view to my view, because I am actually using a horizontal scroll view with a Flex layout inside.
Here is the structure :

Now I've tried two options :
1- Use of Scrolled event in the scroll view but that hasn't been a great option because it fire the events (animation or transition) after the scroll is done, in my case it should fire the event since scrolling started.
2- Use of SwipeGestureRecognizer on Scrollview, FlexLayout and BoxView : couldn't get a stable behaviour on the 2 first attempts but when I used a BoxView I couldn't get each StackLayout (the StackLayout is my card) inside the BoxView (It wasn't built for that).

Here is my UI after I used a horizontal scroll view :

here is the behaviour I wanted to reproduce to my view :
https://media.giphy.com/media/l0NwH3XDSYhQ6l4TC/giphy.gif

Is it possible to call an asynchronous method from a synchronous method?

$
0
0

Hello everyone,

I'm having a Xamarin.forms application and what I'm trying to do is:
1) someone clicks on an item in a listview
2) the application shows a dialog to the user
3) the application waits until the user has pressed "yes" or "no"
4) as soon as there's input from the user, the application (code) continues again

I know that normally it's possible to make your method async and then apply an await on the DisplayAlert. However, because the code is so enormous, changing the method to async has a lot of effect on the rest of my code.. So I wondered if it's possible to call/await an asynchronous method from a synchronous method?

To show the dialog, I use the following code:

private async Task<bool> ShowDialog()
{
return await DisplayAlert("Question?", "Waiting for user input", "Yes", "No");
}

And to await the message box I use the following the code:

public void SyncMethod()
{
// Showing the listview here
// The user clicks an item
bool result = await ShowDialogAsync();

// after the user has clicked something,
// then continue with more code here.
if (result)
// Result = true
}

Unfortunately the SyncMethod needs to be async. Is there a way to solve this without making this method async? Thanks for the answer :)

Viewing all 204402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>