Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 58056 articles
Browse latest View live

Geolocator gps code getting error when select ios project.

$
0
0

Hi, i am using Geolocator and i am gatting Latitute and Longitude for android But when i select ios project i am gatting error on timeoutMilliseconds->(the best overload for 'GetpositionAsync' does not have a parameter name 'timeoutMilliseconds ')
this is my code

async void Handle_Clicked(object sender, System.EventArgs e)
{
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync(timeoutMilliseconds: 10000);
logi.Text = position.Latitude.ToString();
lati.Text = position.Longitude.ToString();
}

note-> it is working properly in android put when i select ios project i am gating this error message .

plese help me


iOS Icon Madness! Can't submit app

$
0
0

So I have seen lots of posts regarding issues with icons and app submission to the App Store. None of them seems to resolve my issue. I have tried both the Asset Catalog and info.plist methods and both fail.

  1. Asset Catalog - Gets an error that the 57x57 and 72x72 icon is missing. There are not spots for that in the asset catalog. I tried to hack the project file and catalog to include the files but no luck.
  2. info.plist - This hack allows the app to be submitted, however it gets rejected during processing. The error is: "Missing Asset Catalog - Your app is missing the asset catalog file in 'MineChat.iOS.app'"

So I cannot figure out how to get this app submitted. I am using Visual Studio 2017 on Windows and using current Stable channel. Any ideas here?

Thanks!

Using Google Maps for iOS on Xamarin Forms

$
0
0

Okay, I have this app that I need to render Google Maps on both iOS and Android. Xamarin.Forms.Maps renders its native maps based on the OS used by the device e.g. Google Maps for Android and MapKit for iOS which makes it easier for the Android to have Google Maps of course. What I want to achieve here is to also have Google Maps for iOS since the main map that we are using is Google Maps. How can I possibly be able to achieve this?

Thanks in advance.

Android Application minimize issue

$
0
0

I have developed an Xamarin forms application. In Android devices Lenovo K6(v7.0) and Nexus 6 (v7.1.1), when the app is minimized and opened by clicking the app icon the opening page of the application is reset to default instead of showing the part in the page where the user has minimized the application. But, when the app is minimized and re-opened using the recent opened tabs it is resumed correctly.

This problem arises only in the mentioned two devices in all other devices the page is resumed from where it is minimized when the user re-opens the application on using both recent tabs or App icon click. If close application then reopen it and application start from Splash screen. In above scenario, app start with home page and reset as default launch. I have started download in my app and progressing the download. I have minimized the app and click app icon from installed app in device. Now, progress is reset and file stay as download me.

Please suggest on this to resolve it.

Regards,

Cheran

360 images in Xamarin Forms

$
0
0

Hi mates,

I'm checking the viability of ussing a 360 image in Xamarin Forms. I have been researching but I haven't found any component so I'm very frustrated.

I have seen this github repo (Github Xplat GoogleVR) but I don't know if it's valid because the GoogleVR target is too old.

Have someone any experience in this topic? Exists any 360 viewer in Xamarin Forms?

Thank you sou much.

How to make the list on the right

$
0
0

help me
How to make the list on the right

How to display alert only once

$
0
0

How can i display an alert only once.
I am calling the alert on appearing

async private void ADALAuthenticate()
{
Version ver1 = new Version(obj.Android.VersionNumber);
Version ver2 = new Version(Settings.GetCurrentVersionSettings);
if (ver1 > ver2)
{
var install = await DisplayAlert("Version " + ver1 + " available", "New version of application available. Please, update for new features, "Install Now",
"Later");
}

I need to display the alert only once until there is a change in version number.

SiriKit works but not when using "Hey Siri"

$
0
0

Hi everyone,

In my Xam Forms app, I have a Sirikit integration which works fine when you hit the iPhone menu button: you can say "Send a message with MyApp" and Siri confirms and sends it and executes my App logic.
But whenever I say "Hey Siri, send a message with MyApp" SIRI tells me "you have to continue in the app".

I have no idea what the difference is between touching the menu button or saying "hey Siri"

Can someone point me in the right direction?

Thanks
Thomas


Sqlite UWP after insert returning wrong Id

$
0
0

I'm using Sqlite in my application using Xamarin Forms .
My code works in Android and IOS project but in UWP it returning wrong result.

 public Task<int> InsertProgram(Program program)
        {
            return database.InsertAsync(program);
        }

in UWP returning Id is wrong ?

Customize ImageEntry in xamarin forms

$
0
0

Hi Xamarin Friends Today i have to creating custom image entry but im stuck this point

Loading Indicator with message.

$
0
0

i am trying to connect mobile via Bluetooth at that time i want to show indicator with message, how can i do this?

How do you add a StackLayout to a ScrollView at runtime using C#

$
0
0

Hi,

I would like to create a stacklayout control filled with controls using C# and then wrap this stacklayout inside a ScrollView. My code is as below.

public partial class MainPage : ContentPage
{

    public MainPage()
    {
        InitializeComponent();
        this.Content = this.BuildView();
    }

    private Layout BuildView()
    {
        StackLayout stackHeaderInv = new StackLayout()
        {
            Padding = new Thickness(0, 10),
            HorizontalOptions = LayoutOptions.FillAndExpand,
            BackgroundColor = "Gray" ,
        };

        //Custom control definition
        ...

        Button btnComplete = new Button() { Text = "Order Complete", HorizontalOptions = LayoutOptions.Center};
        btnComplete.Clicked += btnComplete_Clicked;

        stackHeaderInv.Children.Add(CustomControl);

        StackLayout stackAll = new StackLayout()
        {
            Padding = 0,
            Spacing = 0,
            Children =
                { stackHeaderInv, btnComplete }
        };

        return stackAll;
    }

Now I would like to add more controls to the stacklayout and so I need to use a ScrollView to scroll this page. I would like to know how to add the ScrollView to this BuildView() method in C#. Due to some reason I am not able to create this page with XAML and so have to use C# to create the page.

Thanks.

Rajesh.

add items to ObservableCollection throw an exception

$
0
0

Hi,

I have very strange problem,
I have 4 Content pages, uses the same viewmodel, the process of adding new elements to the ObservableCollection is defined inside the view model,
3 of the 4 pages working perfectly and I can do "load more" and "pull to refresh" inside them,
the 4th page not working, it still blank, after debugging I found the their is an exception thrown when adding a new element to the ObservableCollection,
the exception is:

NSInternalInconsistencyException Reason: Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).

P.S: I am binding the ObservableCollection to listview item source.
P.S: again, 3 of 4 of the pages working perfectly
P.S: this problem shown after updating to latest version of Xamarin (in order to target iPhone X)

my Code is:

private async Task fillList(bool isRef = false)
        {
            try
            {
                if (articles.Count > 0)
                    articles.Clear();
                List<Article> t = new List<Article>();
                t = App.DB.getArticlesByType(articleType);
                if (isRef || t == null || t.Count == 0)
                {
                    if (articleType == 0)
                        t = await App.restClient.getMainArticles();
                    else if (articleType == 1)
                        t = await App.restClient.getMyListArticles();
                    else if (articleType == 2)
                        t = await App.restClient.getReadLaterArticles();
                    else if (articleType == 3)
                        t = await App.restClient.getMostReadArticles();
                    for (int i = 0; i < t.Count; i++)
                        t[i].artType = articleType;
                    App.DB.insertAllArticles(t);
                }

                headImage = t[0].Image;
                headTitle = t[0].Article_title;
                headCategory = t[0].Category;
                headAuthor = t[0].Author;
                head_is_read_later = t[0].Is_read_later == "yes" ? "yes" : "no";
                headArticle = new Article()
                {
                    Article_id = t[0].Article_id,
                    Article_name = t[0].Article_name,
                    Article_title = t[0].Article_title,
                    artType = articleType,
                    Author = t[0].Author,
                    Category = t[0].Category,
                    Content = t[0].Content,
                    ID = t[0].ID,
                    Image = t[0].Image,
                    Is_read_later = t[0].Is_read_later == "yes" ? "yes" : "no",
                    myId = -1
                };

                for (int j =  1 ; j < t.Count; j++)
                {

                    t[j].myId = j + 1;
                    t[j].Is_read_later = (t[j].Is_read_later == null) ? "no" : t[j].Is_read_later;
                    this.articles.Add(t[j]); // the exception thrown in this line
                }
            }
            catch (Exception ex)
            {
                //await App.Current.MainPage.DisplayAlert("خطأ", ex.Message, "موافق");
            }
        }

Local Notification Forms sample do not work for iOS

$
0
0

Hello :smile:

I am trying to work with Xamarin.Form. To get a overview I want to write an application that shows on all plattforms (UWP, ANDROID, iOS) a local notification.

For UWP it worked perfectly!

I am using dependency injection.

For iOS I have this Code here. And this do not work. The Notification is never shown!

There is no crash and monitoring the code with a breakpoints do not Show any problems.

    public void SetGeofence(List<GeoLocation> GeofencesInformationList)
    {
        var locationManger = new CLLocationManager();

        locationManger.RequestAlwaysAuthorization();
        locationManger.RequestWhenInUseAuthorization();


        if (CLLocationManager.LocationServicesEnabled)
        {
            if (CLLocationManager.Status != CLAuthorizationStatus.Denied)
            {
                if (CLLocationManager.IsMonitoringAvailable(typeof(CLCircularRegion)))
                {
                    locationManger.DidStartMonitoringForRegion += (o, e) => {
                        Console.WriteLine("Now monitoring region {0}", e.Region.ToString());

                        showNotification("Test", "Test!");

                    };

                    locationManger.RegionLeft += (o, e) => {
                        Console.WriteLine("Just left " + e.Region.ToString());
                    };

                    locationManger.RegionEntered += LocationManger_RegionEntered;

                    foreach (var item in GeofencesInformationList)
                    {
                        locationManger.LocationsUpdated += LocationManger_LocationsUpdated;

                        CLCircularRegion region = new CLCircularRegion(new CLLocationCoordinate2D(item.Latitude, item.Longitude), item.radius, item.ID);
                        if (!locationManger.MonitoredRegions.Contains(region))
                        {
                            locationManger.StartMonitoring(region);
                        }

                    }

                }
            }
        }

    }


    private void LocationManger_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
    {
        showNotification("View Alert", "Location Updated!");
    }

    private void LocationManger_RegionEntered(object sender, CLRegionEventArgs e)
    {
        Console.WriteLine("Just entered " + e.Region.ToString());

        showNotification("View Alert", "Just entered");

    }


    private void showNotification(string Header, string Content)
    {
        UILocalNotification notification = new UILocalNotification();
        notification.AlertTitle = "Alert Title"; // required for Apple Watch notifications
        notification.FireDate = NSDate.FromTimeIntervalSinceNow(15);
        notification.AlertAction = Header;
        notification.AlertBody = Content;
        UIApplication.SharedApplication.ScheduleLocalNotification(notification);
    }

In App delegate i tried to add this Code here https://developer.xamarin.com/guides/ios/platform_features/user-notifications/deprecated/local_notifications_in_ios_walkthrough/

and also tried this

if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// Ask the user for permission to get notifications on iOS 10.0+
UNUserNotificationCenter.Current.RequestAuthorization(
UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
(approved, error) => { });
}
else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
// Ask the user for permission to get notifications on iOS 8.0+
var settings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
new NSSet());

    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

}

in info.plist I added this keys.

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Test</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Test1</string>

It would be awsome if someone can help me. I really want to write code in Xamarin.Forms.

I dont want to use the Plugins because i want to learn it first step by step.

Thanks

Agredo

How to send data to Web API server and test it through Postman

$
0
0

Hi, I'm having a little trouble trying to send 2 variables to the server and read them
I'm still new to Xamarin so I don't know what to do exactly to make this happen
in the Web API I have this class :

public class ImageMV
{
    public string Name { get; set; }
    public HttpPostedFileBase File { get; set; }
}

and in my Xamarin app I have 2 variables :

ImageName -> contains the file path to the image
byteFile -> byte[] variable of the image

I want to send these two variable to this Url : " myUrl/api/ged/UploadFile"

I believe it will work with HttpClient but I don't know how to apply it to this case

Thank you kindly in advance


How to style images

$
0
0

Good day everyone , how do i style my images on my application to make them circular using c# not XAML

XamSvg: How do I specify SVG files in local storage to be loaded to the view?

$
0
0

Hi, I'm struggling to understand how to load SVGs into the XamSvg.XamForms.SvgImage view, whenever I attempt to load an SVG I get the image displayed "SVG not found", however I am not sure where XamSvg is looking for files. I have added the lines

            XamSvg.Setup.InitSvgLib();
            XamSvg.Shared.Config.ResourceAssembly = typeof(App).GetTypeInfo().Assembly;

to the App.xaml.cs file and put images in an images folder in the same location as App.fs then initialise a view:

let svgV = XamSvg.XamForms.SvgImage(WidthRequest = 500.) 
svgV.Svg <-  "res:images.1"

Problem with messagingCenter

$
0
0

Hello,
I've a problem using messages to drive the navigation from an async call.
I try to explain better. My problem is really simple: I've a login page. In this page I subscribe to navigate when a certain message is received:

MessagingCenter.Subscribe<ViewModelBase,string>(this, HelperClass.LOGIN_SUCCESSFULL, (sender, username) =>
            {
                ServiceLocator.Current.GetInstance<INavigationService>().NavigateTo(ViewModelLocator.CouponsPageKey, username);
            });

Then, in its viewmodel, when a user press the login button, a relaycommand is triggered to make an async call to a WCF, in this way:

 public RelayCommand LoginCommand
        {
            get
            {
                return _loginCommand
                       ?? (_loginCommand = new RelayCommand(
                           () =>
                           {
                               Loading = true;
                               HelperClass.ClientWS.LoginAsync(Username, Password);
                           }));
            }
        }

When this service has replied the handler is triggered

    void ClientWS_LoginCompleted(object sender, ValidazioneUtenteCompletedEventArgs e)
    {
        var _res = e.Result;

                if (_res)
                {
                    MessagingCenter.Send<ViewModelBase, string>(this, HelperClass.LOGIN_SUCCESSFULL, Username);
        }
    }

I can see that the message is correctly received because with the debugger the navigateTo is executed.

What's the strange?
Is that in this way I can't see my app navigate to the new page, while if inside of my LoginCommand instead to call the

HelperClass.ClientWS.LoginAsync(Username, Password);

I directly send the message the navigation occurs correctly.
What's wrong?

Thank you

Xamarin.Forms Editing photo before saving it

$
0
0

I started using MediaPlugin to make photo in my app and it's working perfectly (making photo, saving into gallery and then showing me it). But can i somehow edit it (draw on it like on canvas) before saving it to gallery ?

Unexpected fail for task "javac"

$
0
0

I have this message and the message say that i can have folder or file name long too big, but i have no folder or file name. See below the complete message:

Falha inesperada da tarefa "Javac". System.IO.PathTooLongException: O
caminho especificado, o nome do arquivo ou ambos são muito longos. O
nome de arquivo totalmente qualificado deve ter menos de 260
caracteres e o nome do diretório menos de 248 caracteres. em
System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength,
Boolean checkInvalidCharacters, Boolean expandShortPaths) em
System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength,
Boolean expandShortPaths) em System.IO.Path.NormalizePath(String
path, Boolean fullCheck, Int32 maxPathLength, Boolean
expandShortPaths) em System.IO.Path.GetFullPathInternal(String
path) em System.IO.FileInfo.Init(String fileName, Boolean
checkHost) em System.IO.FileInfo..ctor(String fileName) em
Xamarin.Android.Tasks.ZipArchiveEx.AddFiles(String folder, String
folderInArchive) em
Xamarin.Android.Tasks.ZipArchiveEx.AddDirectory(String folder, String
folderInArchive) em Xamarin.Android.Tasks.Javac.Execute() em
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
em
Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

It was workin. I made an update on my Visual Studio and now i cannot work fine my app.

What am i doing wrong and how can i solve this?

Viewing all 58056 articles
Browse latest View live


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