How to read Wi-Fi SSID in both platforms | iOS - flutter

I need to read Wi-Fi SSID from a Flutter app.
I am using this plugin
I use in a async function this code
String _SSID = await Wifi.ssid;
How can I configure the iOS platform in Xcode to make it work? Now it returns null.

That plugin doesn't support iOS, and short of implementing the iOS side yourself that probably isn't going to change any time soon. Use the connectivity plugin instead:
var wifiBSSID = await Connectivity().getWifiBSSID();
var wifiIP = await Connectivity().getWifiIP();
var wifiName = await Connectivity().getWifiName();
The plugin documentation describes what steps to take to get it enabled for iOS.

Related

How can we implement "Host Card Emulation (HCE)" with Flutter?

We are working to implement HCE in flutter but till now can only read tag's information from the iOS version using the following codes -
void _readTag() {
NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async {
print("_tagRead:${tag.data}");
result.value = tag.data;
NfcManager.instance.stopSession();
});
}
Ref: https://pub.dev/packages/nfc_manager
Last time I checked, Apple wasn't supporting HCE yet (and it was 1 year ago or so).
If you need to implement it on Android only, you can use the nfc_emulator library
did you reach anything in making payment app by NFC ?

Why does my Flutter app crash when attempting to launch Apple Maps?

I am attempting to launch Apple Maps using Launch and a Url, only thing is that it crashes with no error message and I'm not sure why. The Url looks like so: http://maps.apple.com/?saddr=&daddr=
I check if it's Android or ios and build out the urls like this
if (Platform.isAndroid) {
{
await launch("$androidURL${widget.name} ${widget.city}, ${widget.state}");
}
} else if (Platform.isIOS) {
await launch("$iosURL${widget.name} ${widget.city}, ${widget.state}");
}
}
It has worked in the past but doesn't seem to work anymore. Right after it hits the line to build the url and launch maps it loses connection to the emulator and stops, how do I prevent this and just have it open maps as intended? Attached below is my flutter doctor. If I left any essential info out let me know and I'llm include it. Thanks all!
Assuming that you have done the configurations that are needed to use the url_launcher plugin, you can try
await canLaunch(_url) ? await launch(_url) : throw 'Could not launch $_url';
This way you can at least identify the error;

How can i access cross-platform(android/iOS) bluetooth detection for flutter?

Newbie here. I am trying to make a hybrid mobile app in flutter that will detect nearby Bluetooth devices based on some unique ID. I want to read that unique ID from the endpoint and compare it onto the DBMS. I want this for both android as well as iOS.
For reference following code is from nearby_connections plugin but is only for android. https://pub.dev/packages/nearby_connections
bool a = await Nearby().startDiscovery(loggedInUser.email, strategy,
onEndpointFound: (id, name, serviceId) async {
print('I saw id:$id with name:$name');
This flutter package seems compatible with Android and iOS, mayb you can try it : https://pub.dev/packages/flutter_nearby_connections

Open video call flutter

Is there a solution yet for opening the video call function on the native phone in flutter? I have looked at Agora and others and none of them work the way we need them to.
That was rather annoying to research and come up with, here it goes. This is the best I can come up with while keeping high complexity and paid SDK's outside the solution.
First of all, you have to differentiate between the two platforms (iOS/Android) before initiating the video call. Since there's no uniform solution for both platforms AFAIK.
import 'dart:io';
if (Platform.isAndroid) {
// Android Video Call
} else if (Platform.isIOS) {
// iOS Video Call
}
iOS
Install the infamous url_launcher pub.
You'll need to use FaceTime Links (see full iOS URL Scheme Reference here or here)
Text example: facetime:14085551234 this initiates FaceTime video call to 14085551234 (you use email instead of phone number too)
import 'package:url_launcher/url_launcher.dart';
final String url = 'facetime:$phoneNumber';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
This works surprisingly well. In this case you can replace $phoneNumber variable with something like $userEmail variable.
Android
Install android_intent pub
Add CALL_PHONE permission and show its prompt to user if you're using android.intent.action.CALL, or just use android.intent.action.DIAL without the permission.
This is where the problem lies... I tried the following solution and it only worked for regular calls not video calls
import 'package:android_intent/android_intent.dart';
/// This acton calls the user directly via native phone app but requires `CALL_PHONE` permission in _AndroidManifest_.
final callIntentAction = 'android.intent.action.CALL';
/// This action displays native phone app with dial pad open showing the passed phone number intent's argument/extra. Does not require permissions as of Jan2020.
final dialIntentAction = 'android.intent.action.DIAL';
final intentAction = callIntentAction;
AndroidIntent intent = AndroidIntent(
action: intentAction,
data: Uri.encodeFull('tel:$phoneNumber'),
arguments: {
/// KEY: actual phone number to call [source](https://developer.android.com/reference/android/content/Intent.html#EXTRA_PHONE_NUMBER)
/// VALUE: phoneNumber
'android.intent.extra.PHONE_NUMBER': phoneNumber,
/// KEY: [START_CALL_WITH_VIDEO_STATE](https://developer.android.com/reference/android/telecom/TelecomManager.html#EXTRA_START_CALL_WITH_VIDEO_STATE)
/// VALUE: `3` implies [STATE_BIDIRECTIONAL](https://developer.android.com/reference/android/telecom/VideoProfile.html#STATE_BIDIRECTIONAL)
'android.telecom.extra.START_CALL_WITH_VIDEO_STATE': '3',
},
);
await intent.launch();
Error-handling side-note: unfortunately with android_intent pub there's no error handling or "canOpen" method like url_launcher.
Your problem still lies with Android as there's no native general-purpose video-call app.
You have a couple of options:
A. You can link with your app a video-calling SDK/capability either third-party or your own. (like flutter_webrtc, agora_flutter_webrtc, SightCall, quickblox). This has the downside that the callee has to be using the same software i.e. your app has to be installed on callee's device. This approach is more future-proof. Note I'm not affiliated with any of the libraries I mentioned.
B. You can make a platform method for Android to go over a defined set of intents and check the package name of known video-calling apps with the extra/arguments they require. You'd have to check the list of intents one by one and see which applies and resolves correctly. For apps like Google Duo, Whatsapp, Skype, etc.... This is EXTREMELY prone to errors. As explained here.

How to determine if flutter is running in simulator

Is there a call to determine if flutter is running within a simulator or a physical device?
I am scanning QR codes, and want to bypass, since the camera is unavailable.
I expected to find this in platform.dart[1] but it's not there.
[1]https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/foundation/platform.dart
I imagine I can create a plugin if I really need, I'm hoping it already exists.
Using the device info plus plugin you can get various information about the device you're running on, including 'isPhysicalDevice' for both Android and iOS (although you'll have to read them independently).
2021 Update
It‘s now part of Flutter Community Plus (https://plus.fluttercommunity.dev/)
Device Info Plus Docu: https://plus.fluttercommunity.dev/docs/device_info_plus/overview
e.g.:
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if(Platform.isIOS){
var iosInfo = await deviceInfo.iosInfo;
if(iosInfo.isPhysicalDevice){...}
}
I Know I'm A Bit Late, But If Anyone Else Comes Here, This Can Help Them.
You Can Just Use This Package:
https://pub.dev/packages/safe_device
Add The Latest Version In Your Pubspec.yaml File
Then import it:
import 'package:safe_device/safe_device.dart';
Then You Can Check If Device Is An Emulator:
bool isRealDevice = await SafeDevice.isRealDevice;
No.
But what you can do instead is use different configurations (such as a dev configuration).
For this you can use a different main.dart such as main.dev.dart and then run it with flutter run -t lib/main.dev.dart
I'm using https://pub.dev/packages/flutter_is_emulator
import 'package:flutter_is_emulator/flutter_is_emulator.dart';
....
bool isAnEmulator = await FlutterIsEmulator.isDeviceAnEmulatorOrASimulator;