I am trying to do something super simple just launch the android or apple play store from my app so a user can go rate the app from my settings but I get this error when testing in my iOS simulator:
Safari cannot open the page because the address in invalid
onTap: () {
if (Platform.isAndroid || Platform.isIOS) {
final url = Uri.parse(
Platform.isAndroid
? "https://play.google.com/store/apps/details?id=com.dontforgetthespoon.dont_forget_the_spoon"
: "https://apps.apple.com/us/app/dont-forget-the-spoon/id6444052519?platform=iphone",
);
launchUrl(
url,
mode: LaunchMode.externalApplication,
);
}
}
I feel like this should be super simple. Any ideas on what may be going wrong for me? Thanks!
The easyiest way is to use launch_review flutter package.
LaunchReview.launch(androidAppId: "com.example.app",
iOSAppId: "511431312");
Related
Firstly : i went through many ( MANY ) post about this problem, tested them all, but it seems that i'm cursed, or something like that ?
I'm working on expo with the LAN method, on iOs.
My back is on .Net Core 3.
My iPhone is on the same Wifi than my computer.
And my computer is running my .Net back server.
I found at that localhost cannot be handle by expo/react-native. So i tried the IP adresse method and change my back adress and the adress that my front was trying to fetch.
Tried the infoPlist with expo. Tried some mysterious things that i don't fully understood with my .Net server. Also tried to turn off my firewall, it didn't change anything.
Well, i'm not used to post because existing posts often answer my question.
Here is my code about my fetch method :
export async function callPlanning() {
try {
let response = await fetch(
"http://my.Ipv4.adress:myApiPort/myRoute",
);
let responseJson = await response.json();
return responseJson;
} catch (error) {
console.error(error);
}
}
My Api is working well on Postman.
And i can call the facebook test api with this function within my app.
Here is my app code where i'm calling this fetch function :
export default class BetaserieScreen extends Component {
constructor(props) {
super(props)
this.state={
response: null,
};
this.askPlanning = this.askPlanning.bind(this);
}
askPlanning = () => {
this.setState({
response: Back.callPlanning(),
})
}
render() {
return (
<View style={styles.MainContainer}>
<Text> Beta Serie </Text>
<TouchableHighlight onPress={this.askPlanning}>
<Text>Planning</Text>
</TouchableHighlight>
</View>
);
}
}
If you see anything that could andwer my question or about my code : i'll take it.
I'm on it for 2 days, and i've to find a solution...
If you need any other information about my system or file about my project, feel free to ask for it if you think you can help me with this problem.
I'll be glad.
the reason is ios blocks the requests made with http protocol by default
check in here https://reactnative.dev/docs/network
Configuring my app to work with OAuth. Once I have the auth_code from the redirect uri, I want the user to be taken to a "log in loading" page, where a loading spinner is shown while the token exchange request is happening.
The app has been properly configured iOS side to allow deep linking, and I am being brought back to the app, just to the wrong page.
I have followed the official deep linking guide from React Navigation, as well as various Stack Overflow pages and Medium articles.
This is my App.tsx component:
const prefix = 'myapp://'
export const App = () => {
return (
<ThemeProvider theme={theme}>
<Routes uriPrefix={prefix} />
</ThemeProvider>
)
}
This is my Routes.ts:
const AuthStack = createStackNavigator({ Onboarding: OnboardingFlowScreen, SignIn: SignInScreen })
const AppTabBar = createBottomTabNavigator({ Feed: FeedScreen, Create: CreateScreen, Profile: ProfileScreen })
export const Routes = createAppContainer(
createSwitchNavigator({
AuthLoading: AuthLoadingScreen,
LogInLoading: { screen: LogInLoadingScreen, path: 'auth_success' },
App: AppTabBar,
Auth: AuthStack,
})
)
I should be brought back to the app and navigated to the LogInLoading screen. Am I misunderstanding? Shouldn't Linking.openURL('myapp://auth_success') take me to the page with path auth_success specified?
The URL can only launch your application.
To take the user to a particular screen, you need to provide navigation context based on the URL.
Whenever your app is opened through a remote URL, you get a call back in AppDelegate in method AppDelegate.application(_:open:options:) Here you can navigate to the screen you want.
Offocial Apple Documentation on URL Scheme
Refer to a question here IOS: Load a View Controller When App is Launched from Browser using url schemes?
I want to make a Flutter app and one of the requirements is to open the native email client on the Android or iPhone device. I do NOT wish to create a new email, just open the email app. I would like to be able to open the email client with platform generic code if possible, if not I would like to know what would be required on the iOS side. I am not looking for the Send Email Intent, as I know there is a plugin in Flutter for that. Being a Android Developer I believe I know how to call an Intent from Flutter for that Implicit Intent, if I have to go that way, but I don't have the familiarity with iOS.
The url_launcher plugin does that
mailto:<email address>?subject=<subject>&body=<body>
Create email to in the default email app
See also How do I open a web browser (URL) from my Flutter code?
You need two plugins: android_intent and url_launcher
if (Platform.isAndroid) {
AndroidIntent intent = AndroidIntent(
action: 'android.intent.action.MAIN',
category: 'android.intent.category.APP_EMAIL',
);
intent.launch().catchError((e) {
;
});
} else if (Platform.isIOS) {
launch("message://").catchError((e){
;
});
}
use url_launcher plugin url_launcher
Future<void> _launched;
Future<void> _openUrl(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
Then for Phone
setState(() {
_launched = _openUrl('tel:${+917600896744}');
});
for email
setState(() {
_launched = _openUrl('mailto:${sejpalbhargav67#gmail.com}'');
});
Update July 2021
Add Following Lines in Manifest File
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
launch("mailto:<email address>?subject=<subject>&body=<body>");
use url_launcher package
You can use email_launcher
Example
Email email = Email(
to: ['one#gmail.com,two#gmail.com'],
cc: ['foo#gmail.com'],
bcc: ['bar#gmail.com'],
subject: 'subject',
body: 'body'
);
await EmailLauncher.launch(email);
I'm using open_mail_app: ^0.4.5 for this, it works pretty well and it took 2 min to add it to my app:
// Android: Will open mail app or show native picker.
// iOS: Will open mail app if single mail app found.
var result = await OpenMailApp.openMailApp();
It shows all 3 of my email apps that I have installed on my android smartphone, but for some reason it also gives the option to open my paypal app, which could make users of my app think to be a bit sus.
The developer of open_mail_app has added a filter to filter out paypal, but it seems not to work:
/// Default filter list includes PayPal, since it implements the mailto: intent-filter
/// on Android, but the intention of this plugin is to provide
/// a utility for finding and opening apps dedicated to sending/receiving email.
U can use url_luncher:
await launchUrl(Uri.parse("mailto:email?subject=subject&body=body"))
& don't use launch as it's deprecated:
launch("mailto:<email address>?subject=<subject>&body=<body>");
this answer may be the solution How to open default email app inbox in flutter?
void openEmailApp(BuildContext context){
try{
AppAvailability.launchApp(Platform.isIOS ? "message://" : "com.google.android.gm").then((_) {
print("App Email launched!");
}).catchError((err) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("App Email not found!")
));
print(err);
});
} catch(e) {
Scaffold.of(context).showSnackBar(SnackBar(content: Text("Email App not found!")));
}
}
You can use this package to open mail app in a device,https://pub.dev/packages/open_mail_app
In theory this line of code should resolve the problem
String email = 'yourEmail#domain.com';
String title = 'The subject';
String message = '';
await launch(mailto:$email?subject=$title&body=$message);
But for some reason the subject and body are ignored, and to solve this issue check out this answer, it should work smoothly for all required parameters.
the working code:
final Uri params = Uri(
scheme: 'mailto',
path: email,
query: 'subject=$title&body=$message',
);
var url = params.toString();
await launch(url);
This library solved it perfectly for me: https://pub.dev/packages/flutter_email_sender. The example is good and the api is simple and obvious.
I was looking for a similar solution and I found this package Open_mail_app. You can read through the readme.md on how to use it in your app.
[I will update this answer soon]
It been two days I'm working with twitter and google plus Signup/Signin but unfortunately unable to hit it.
For twitter, I tried Aaron K Saunders's test app https://github.com/aaronksaunders/test_social. It says "You've granted access to your app. Next, return to your app and enter this PIN (XXXXXXX) to complete authentication process". What really is that??? I'm confused in it.
For google plus, I tried Google Auth for Titanium test app https://github.com/ejci/Google-Auth-for-Titanium. But it shows simple white screen.
I'm stuck into both of these. Can anyone please help. I'd be grateful.
Thanks a lot!!
I believe you posted this issue on Test Social's GitHub page? Here's what I had to do to get Twitter working on Android - Test Social still works as intended on iOS.
"I have the same issue (Android only, iOS still works as before). This is an issue with Android, not this module. Here is how I go about fixing this on Android.
getHtml on the webView is returning null in Android, but again fine in iOS - Just putting this out there in case anybody runs into this error. Doesn't seem to be a fault of this module.
I modified the authorizeUICallback function inside Test Social:
function authorizeUICallback(e) {
var promptView = Ti.UI.createView({
width:'30%',
height:'10%',
layout: "vertical",
backgroundColor:'black',
bottom:"20%"
}),
pinField = Ti.UI.createTextField({
width: Ti.UI.FILL,
height: Ti.UI.SIZE,
hintText: 'Enter PIN'
}),
pinButton = Ti.UI.createButton({
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
title: "Authorize"
});
promptView.add(pinField);
promptView.add(pinButton);
view.add(promptView);
pinButton.addEventListener('click', function() {
if (!pinField.value) {
alert('No PIN found');
} else {
pin = pinField.value;
response = 1;
response ? ( pin = pinField.value, /*pin = response.split("<code>")[1].split("</code>")[0]*/ destroyAuthorizeUI(), receivePinCallback()) : (loadingView && loadingView.hide(), loadingContainer && loadingContainer.hide(), webView && webView.show()), loading = !1, clearInterval(intervalID), estimates[estimateID] = (new Date).getTime() - startTime, Ti.App.Properties.setString("Social-LoadingEstimates", JSON.stringify(estimates));
}
});
}
There was another issue created on the GitHub page and they haven't found a solution either. This seems to be the only way to get Twitter to work with Test Social (or the ONLY way I've found to get it to work with Appcelerator at all).
I can't help you with Google+ just yet. I'm looking to implement that later, but it's not super high on my priority list with their recent changes... Who knows how much longer people will be using it, but I digress... Are you getting any kind of error in the console when you get a 'white screen'?
My iOS build of my app does not seem to want to connect to the internet at all. Can someone point me in the right direction with this?
I've added the address that I am trying to connect to, to the white list. Though I am not sure where to start with this as this is my first iOS app. I'm not sure if there is an error generated some where that I'm not seeing.
The app builds fine and is pushed to both the Simulator and a physical iPhone. It works on the Simulator. The iPhone has a connection and can browse the web so I know that is not the issue.
Let me know what else you may need to help with this as I'm not sure what I need to provide.
Edit
Below script logs the user into the system using a backbone.js model which sends an ajax request to the server. This works fine on the Android Build.
App.user = new App.model.user({
'email' : $(event.currentTarget).find('#email').val(),
'password' : $(event.currentTarget).find('#password').val()
});
The user model:
App.model.user = Backbone.Model.extend({
defaults : {
"email" : null,
"password" : null,
},
initialize : function () {
this.save(null, {
success : function (model, response) {
App.loggedIn = true;
App.navigate("menu", {
trigger : true,
replace : true
});
App.menu();
},
error : function (model, response) {
try {
App.mainView.error(response.resultMessage);
} catch (e) {
console.log(e);
}
},
wait : true
});
},
urlRoot : App.config.siteUrl + "/gateway/user"
});
I would try the following.
1) Have a dummy html page
< html>
< head>
< script>
window.location.href="Your absolute URL you are trying to reach"
< /script>
< /head>
< body>Loading< /body>
< /html>
If that does not work, set whitelist to * and try again. If it works something wrong in the way whitelist is set
2) See if you are accessing a secure URL. If it works on simulator and doesn't work on phone, see if the phone has access to the URL you are trying to hit. Try using mobile safari.
3) Make sure you are using right cordova file. (The cordova.js is different between Android and IOS)
4) If mobile safari is able to connect, they try using the webview debugger as specified in this awesome post
I think you have to fix you Cordova.plist :
http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html