How can I pass data from one app to another app in flutter? - flutter

I am developing an app in which payment automation is an functionality.
What is required is that Account details need to be filled by my app, so that no need of manual typing.
I know I can open app using url_launcher package, but I don't know how to pass data?
and how to map data with the different textfield of the selected app .

I am going to consider any UPI enabled payment application here and you want to pass data like reciever name, upi ID, total amount and a transactional note.
Future<UpiResponse> initiateTransaction(UpiApp app) async {
return _upiIndia.startTransaction(
app: app,
receiverUpiId: "9078600498#ybl",
receiverName: 'Md Azharuddin',
transactionRefId: 'TestingUpiIndiaPlugin',
transactionNote: 'Not actual. Just an example.',
amount: 1.00,
);
}
You can use upi_india but this is not limited to just upi_india.
You have other packages like stripe and flutter pay which also has similar functionality

Related

Flutter Web Firebase Auth's persistence doesn't work on PWA

I have developed a Flutter Web app that uses Firebase Authentication in order to sign in users to the app.
I've declared the Firebase Authentication persistence field so that the app will remember and auto-login the user when he revisits the Flutter Web app's URL, and won't be required to re-login every time he launches the URL.
It all works fine on a regular browser, but when the user generates a PWA (for example, clicking "Add to Home Screen" on iOS devices to save the website as PWA), the persistence feature stops working, and the user is required to re-login every time he opens the PWA.
Is there a way to add Firebase Authentication's persistence feature to a PWA? And if not, is there a way to prevent generating a PWA (and saving the Flutter Web app as a regular browser URL when clicking "Add to Home Screen" button on iOS, for example)?
Thank you!
To solve the persistence problem, add a listener:
FirebaseAuth.instance.idTokenChanges().listen((User? user) async {
if (user == null) {
// Function for user not logged in here. Do not write function to change page here.
} else {
// As it's a Future it will take a while to process the user's information, so it
will call the function after it's done.
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (_) => Home()));
}
}
This is an example I made and it worked, use controllers to change the status, put some function to wait for the information to be processed.
Hope this helps. Any questions, at your disposal.

Flutter - App Store Connect rejection due to needing "functional link to the Terms of Use (EULA)" in "your app's binary"

Our flutter app, with a subscription membership in-app-purchase, is repeatedly being rejected by App Store Connect for the following reason :
Specifically, we were unable to find the following required
information in your app's binary:
– A functional link to the Terms of Use (EULA)
How do we update the app's binary to have a link to the EULA ?
Does anyone know what this message actually means ?
Note that we do show the EULA when the user first enters the app, and there is link to it - so this message doesn't appear to be about the actual functioning/UI in the app.
Note that this is a Flutter app, so bonus points on the answer if you can tell how to set the EULA in the binary in Flutter. ("bonus points" being an expression, I have no authority from SO to allocate extra points)
As far as I know, they need a button that opens the browser on a public page that contains your Terms of Use/Privacy Policy. This button should be available at all times, not only when the user first opens the app.
You can do that using the url_launcher package. Example:
ElevatedButton(
onPressed: () {
launch('https://policies.google.com/terms?hl=en-US');
},
child: Text('Terms of Use'),
),
I have implemented this a few times and haven't had issues publishing to the App Store.

Flutter integration test firebase auth (email link or google sign in)

I'm adding integration testing (using the integration_test package) to my app but I am running into a problem.
Let me explain. The first step when my app launch is authentication for which I have 3 options: firebase email link, firebase google sign in, and firebase facebook sign in.
What is blocking me is that all these sign in methods require actions outside of the main app dart code and thus are not accessible by flutter driver.
Am I missing something here? And if not how should that case be handled?
Cheers!
To make the test less flaky i would recommend to not rely on an internet connection or a third party (like Firebase or Google login).
I would advise to use a Mock for this. So when you try to login to your test you send a fake response, and in that way you can continue using the app.
The following article explains how to use a mock:
https://medium.com/stuart-engineering/mocking-integration-tests-with-flutter-af3b6ba846c7
You can use Patrol – it lets you interact with native system UI from within your Flutter integration tests. Example:
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';
void main() {
patrolTest(
'signs in',
nativeAutomation: true,
(PatrolTester $) async {
await $.native.enterText(
Selector(textContains: 'Email'),
text: 'tester#awesomeapp.pl'),
);
await $.native.enterText(
Selector(textContains: 'Password'),
text: 'ny4ncat'),
);
await $.native.tap(Selector(text: 'Continue'));
// you should be signed in
});
}
You can add the fourth way of signing in - using username and password. Firebase should support this kind of very common situation, so you can do it within lines of code.
If you do not want the end users to login by password, you can simply disable this method in production build and only enable it in debug build.
Another way is to mock your authentication system. In other words, when doing testing, you have a button called "fake sign in", and your integration test driver just click that button.

how to redirect user number to phone call app flutter

Is there a way I can redirect a user to his/her phone call app with a number when he/she clicks a button?
for a better explanation:
I have an app where you can check people's profiles and then when you click a button in someone's profile. it will redirect you to your phone call app with the person's number from his profile and then choose to call him/her
add url_launcher: ^5.7.10 in you Pubspec.yaml
run flutter pub get
and you can use this function,
call() async {
const tel= {phone number};
try {
await launch(tel);
} catch (_e) { print(_e):}
}
watch out for indentation
regards,
Roshan
Use the url launcher package.
It has the ability to open the correct app depending on what you pass to it in the coded url. For example, if you pass it has http url, it opens the browser. If you pass smtp coded phone number, it opens sms app etc
Url parameter of tel: will launch your phone app
Details here

Ionic Framework Email Composer - How to choose email app

Working on an Ionic Framework app that allows users to send an email. Currently, the app just sends using the device's default email application. Is there any way to allow the user to choose which email app they want to use?
check this link
According to documentation this plugin takes app as a parameter. Like below;
this.email.open({
app: 'gmail',
...
});
By making following changes in your code, it will open gmail app by default-
For details, refer https://ionicframework.com/docs/native/email-composer/
// add alias
this.emailComposer.addAlias('gmail', 'com.google.android.gm');
// then use alias when sending email
this.emailComposer.open({ app: 'gmail', ... });