How can we implement "Host Card Emulation (HCE)" with Flutter? - 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 ?

Related

How to send data from smartwatch to Flutter app

I am looking for a method to get data(heart rate) from a smartwatch(wear/tizen/watch) and read them using a Flutter app. Anyone know of such a package or idea to communicate with the smartwatch and a Flutter APP PLZ?
You can look at this answer which is pretty much what you were asking.
It says that, by now, you can do it only for wear thanks to this package.
Here's an example for receiving messages:
// msg is either a Map<String, dynamic> or a string (make sure to check for that when using the library)
WearableListener.listenForMessage((msg) {
print(msg);
});

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

Back4app with Stripe using swift iOS

I'm trying to build an iOS app with back4app acting as the db. I've added Stripe to the cloud code and I've added all the relevant API keys to it.
I've been following https://www.back4app.com/docs/cloud-code-functions/stripe-android-app as documentation.
Being an Android app, I'm not sure which cloud code functions I should use when trying to test a payment using Swift.
Hope someone can help. Thanks.
Back4App utilises the open source Parse Server and the wider Parse Platform including our open source client SDKs for iOS, Android, JavaScript, Flutter, PHP and more.
With this in mind much of our open source documentation is relevant to using Back4App. The extensive guides should help get you up to speed and answer most simple questions.
Following on from #Paul's suggestion, to call a cloud function using the iOS SDK you can do something like this...
PFCloud.callFunction(inBackground: "purchaseItem", withParameters: nil) { (result, error) in
guard error == nil else {
return
}
guard let result = result as? String else {
return
}
print("Wow \(result).")
}

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.

iphone phonegap application

In phone gap iphone application,I want to display local notification at regular interval.So how can I do that?I found one sample plugin of local notification but it not works, so is their any setting in property list file for display notification?
I made this tutorial / example of how to use the localNotification as well as make a callback to your app...
http://www.drewdahlman.com/meusLabs/?p=84
hope that helps!
For local notifications in iPhone, there is a PhoneGap plugin in the PhoneGap Plugins repo on GitHub: https://github.com/phonegap/phonegap-plugins
The local notification plugin is at:
https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/LocalNotification
It doesn't have a README, but it does have an example.
Thanks for clarifying what you're hoping to do. I don't think their's a built-in local/push notification in PhoneGap, but you can use the tools at http://urbanairship.com to accomplish this.
I'm not sure exactly what you're asking, but it sounds like you want to display a notification.
If that's what you're looking to do, stick this in your JS:
function alertDismissed(button) {
if (button == 1) {
alert('they hit yes');
}
}
navigator.notification.alert(
'Look at this message now!', // message
alertDismissed, // callback
'Look at me!', // title
'Yes,No' // buttonName
);
You'll also need to make sure you're calling the phonegap.js file in your document head.