I'm an iOS developer starting to look into Flutter. I'm following this tutorial from Ray Wenderlich and I'm facing a strange behaviour from this code.
_loadData() async {
var dataURL = "https://api.github.com/orgs/raywenderlich/members";
var response = await http.get(dataURL);
setState(() {
_members = json.decode(response.body);
});
}
Problem is that execution is stopped at var response = await http.get(dataURL);
I know is related to the await but I'm not sure why is happening. On the example code from the http package is using a similar code.
Can anyone help?
Thanks
So, the reason of the unresponsive await was due to the Android simulator. I don't know why but connection is not working on the simulator. I tested with the iOS simulator and worked.
if it is stopped it might be because the url does not return anything, maybe because the url is wrong? also i think string should use single quotations ' instead of ". try replacing it with single quotations?
Related
I've been trying to fix this issue for two days now.
This is a Xamarin.Forms application. The Android side is working perfectly. On the iOS, however, I keept geeting this error.
I have a single button in the center of my screen. When it's clicked, it uses the CrossLocator class to get the Geolocation of the phone. However, this problem keeps ocurring:
Erro: Evento registration is overwriting existing delegate, Either just use events or your own delegate:Plugin.Geolocator.GeolocationSingle-UpdateDelegateCoreLocation.CLLocationManager+_CLLocationManagerDelegate
Here's my code:
`public static async Task<Tuple<Position, string>> GetLocalizacao()
{
var locator = CrossGeolocator.Current;
try
{
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(10000));
}
catch (Exception ex)
{
return new Tuple<Position, string>(null, $"Erro: {ex.Message}");
}
var localizacaoFinal = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(10000));
return new Tuple<Position, string>(localizacaoFinal, "");
}`
The exception happens when it hits "GetPositionAsync". From there on, I don't know what to do, nor how to actually identify the issue itself.
If anyone stumbles upon this post, I've been stuck with this issue since I posted it. Still can't get it to work in these conditions. The only way my app worked was downgrading all packages I needed for this.
In order for it to work, it now has:
Xam.Plugin.Geolocator, version 4.5.0.6
Xamarin.Forms, version 5.0.0.2012
Xamarin Essentials, version 1.6.1
Plugin.Permissions, version 6.0.1
I am using magic_sdk: ^0.3.1 and magic_ext_oauth: ^0.1.0 in flutter to implement a login.
This is the code I am using
try{
Magic magic = Magic.instance;
if (loginType == OAuthProvider.GOOGLE) {
Logger().w('logging with google'); //working
var configuration = OAuthConfiguration(
provider: OAuthProvider.GOOGLE,
redirectURI: 'magicauthentication://');
Logger().w('logging configuration added'); //working
var result = await magic.oauth.loginWithPopup(configuration);
Logger().w('popup passed'); //not working
Logger().w(result.magic!.toJson());
var token = result.magic!.idToken;
exchangeToken(context, token);
}
} catch (e) {
Logger().e(e); //not working
}
This code works fine without any bugs on Android. On iOS it does not. I added loggers to check the executing lines. There are marked in the above code as working and not working.
Since I had to add android schemas to work on Android I also added applinks on iOS
What can be the problem here why it is not giving result only on iOS ?
Is there anything more that I need to add?
as it is clear from the score section of it, it doesn't support multiple platforms, try the recent one.
I'm trying to create a UDP server using SocketLite.PLC in Xamarin.
When running the iOS app I get the error Address already in use regardless of what port I try to listen to.
My code looks like this:
var udpReceived = new UdpSocketReceiver();
await udpReceived.StartListeningAsync(6932, allowMultipleBindToSamePort: false);
Why is this happening, and how can I fix it?
I would try something like this:
using (UdpSocketReceiver udpReceived = new UdpSocketReceiver())
{
//operations
await udpReceived.StartListeningAsync(6932, allowMultipleBindToSamePort: false);
udpReceived.Close();
}
I'm kind of betting on this being a similar issue to a thread I found regarding xamarin and the TcpListener (which can be found here).
I'm working on a Xamarin Forms PCL project targeting Android and iOS that needs some basic barcode scanning functionality.
I got things up and running with the forms version of the ZXing.Net.Mobile package following this tutorial and referencing this guide and it works great on Android. However, on iOS the camera comes up but the OnScanResult event is never fired.
I've tested it on several iOS devices running several different versions (anywhere from 8.0 - 10.3) and fiddled with everything I can think of, referencing their sample projects as well. ZXing.Net.Mobile and ZXing.Net.Mobile.Forms nuget packages were installed in all projects.
Here's my scanner code, triggered from a button press on my main page:
var scanPage = new ZXingScannerPage();
scanPage.OnScanResult += (result) =>
{
scanPage.IsScanning = false;
Device.BeginInvokeOnMainThread(async () =>
{
await Navigation.PopAsync();
await DisplayAlert("Scanned Barcode", result.Text, "OK");
});
};
await Navigation.PushAsync(scanPage);
and AppDelegate.cs:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
global::ZXing.Net.Mobile.Forms.iOS.Platform.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
After two days of fighting with this, I feel like I'm at my wit's end. Has anyone else encountered similar problems? Thanks for any guidance!
Edit 1
Here's the device log output (Message column only) when clicking the button to trigger the above code. No log items are added while the camera is open and pointed at various barcodes. I don't see anything suspicious here, but maybe someone else does?
PERF: Alloc AVCaptureVideoPreviewLayer took 14.14 ms.
AppleH4CamIn::power_on_hardware
AppleH4CamIn::ISP_SelectBestMIPIFrequencyIndex_gated - channel: 0, index: 0
StartScanning
AppleH4CamIn::setPowerStateGated: 1
ZXingScannerView.Setup() took 0.167 ms.
ASL Sender Statistics
AppleH4CamIn::ISP_FlushInactiveDARTMappings: 0x00000000
AppleH4CamIn::ISP_SelectBestMIPIFrequencyIndex_gated - channel: 0, index: 0
Edit 2
I ran the sample Xamarin Forms PCL from the github repo and am having the same problems on iOS with the camera opening fine, but no barcode ever read. Therefore I'm thinking the problem must be with my Visual Studio and/or Xamarin setup. I'm running Visual Studio 2015 Community on the stable Xamarin channel.
add this on ios
protected override void OnAppearing()
{
base.OnAppearing();
qrcode.IsScanning = true;
}`enter code here`
protected override void OnDisappearing()
{
qrcode.IsScanning = false;
base.OnDisappearing();
}
Try using this:
scanPage.IsAnalyzing = true;
IsAnalyzing is different from IsScanning.
I faced the same the issue like you. But after using IsAnalyzing = true; It is fixed.
I finally got it working with this project as a starting point. It's just a basic barcode scanning implementation using ZXing, but for whatever reason I could finally read barcodes on iOS.
It's probably a version-related problem, but I couldn't narrow it down.
Edit
I posted this same question in the Xamarin Forums: https://forums.xamarin.com/discussion/comment/272209#Comment_272209
It seems the answer was downgrading to ZXing version 2.1.47. I haven't done any work with the library for a few months so I haven't tested new versions.
I'm doing a .or query which in every platform works fine except in iOS.
As soon it reaches the line where it does the .or, it crashes with:
System.Collections.Generic.List> doesn't implement interface System.Collections.Generic.IEnumerable>
Assertion: should not be reached at mini-trampolines.c:183
Here's the code:
var isChallenger = ParseObject.GetQuery("Match")
.WhereEqualTo("Challenger",fb.loggedUser);
var isChallenged = ParseObject.GetQuery("Match")
.WhereEqualTo("Challenged",fb.loggedUser);
ParseQuery<ParseObject> query = isChallenger.Or (isChallenged); // Crashes here.
I'm doing it just like in the docs, not sure what's wrong.
Any help would be much appreciated!
Thanks,
Pablo
I think this is a bug I reported here: https://developers.facebook.com/bugs/750897958275392/
Except, I only saw this bug when using ParseQuery. The workaround I used is to use ParseQuery only, but I see you're already doing that. Is the code you posted exactly the same as the code you're actually using?