Login with Apple Id in Flutter? - flutter

Here is my login page, actually it should login, but I got error
I included sign in capabilities in XCODE
Xcode configurations all set
**
Error Message I got : Unhandled Exception: SignInWithAppleAuthorizationError(AuthorizationErrorCode.canceled, The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1001.))**
child: InkWell(
onTap: () async {
final credential =
await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.fullName,
AppleIDAuthorizationScopes.email,
],
);
print(credential);
context.read<SignInBloc>().add(
SignInEvent.signInWithApple(
appleToken: credential.authorizationCode,
),
);
},
Above is my function to sign in with Apple Id

App Identifier create to "Sign in with Apple" checkbox selection
like that

Related

Flutter Apple Sign in not get email,password, and name,surname

the code below allows you to login with apple-id but I can't see the credentials, why?
Flutter Code:
final credentialUser = await SignInWithApple
.getAppleIDCredential(
scopes: AppleIDAuthorizationScopes.values);
print(credentialUser);
try this
final credential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
);

Connect Metamask with a native mobile app built with Flutter

I want to connect the app to Metamask to get the user account and signature from the user to confirm the transaction. But the problem is that when I enter Metamask from the app, I am not asked any questions to confirm the connection and nothing happens inside Metamask, it is like only the Metamask app is opened and when I back up and return to the app, the null account is returned.
_walletConnect() async {
final connector = WalletConnect(
bridge: 'https://bridge.walletconnect.org',
clientMeta: const PeerMeta(
name: 'WalletConnect',
description: 'WalletConnect Developer App',
url: 'https://walletconnect.org',
icons: [
'https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media'
],
),
);
// Subscribe to events
connector.on('connect', (session) => print(session));
connector.on('session_update', (payload) => print(payload));
connector.on('disconnect', (session) => print(session));
// Create a new session
if (!connector.connected) {
session = await connector.createSession(
chainId: 97,
onDisplayUri: (uri) async => {print(uri), await launch(uri)});
}
setState(() {
account = session.accounts[0];
print(account);
});
if (account != null) {
final client = Web3Client(rpc, Client());
EthereumWalletConnectProvider provider =
EthereumWalletConnectProvider(connector);
credentials = WalletConnectEthereumCredentials(provider: provider);
yourContract = ethUtils.getDeployedContract(myAddress, client);
}
It sometimes happened to me as well.
I had just closed the MetaMask app and clicked on the button (Which triggered this function) and it worked fine.
I made a library for this, web3_connect, uses the same code and it gets the address back just fine for me

Open Facebook app with url_launcher package in Flutter

I am trying to open the Facebook app on a company page in Flutter but it keeps opening it in the web browser instead.
It's just a simple widget that outputs a row of social media icons from a list:
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class SocialMediaLinks extends StatelessWidget {
SocialMediaLinks({Key? key}) : super(key: key);
final List<Map<dynamic, dynamic>> icons = [
{
'name': 'twitter',
'launchUrl': 'twitter://PAGENAME',
'backupUrl': 'https://twitter.com/PAGENAME',
},
{
'name': 'facebook',
'launchUrl': 'fb://page/PAGEID',
'backupUrl': 'https://www.facebook.com/PAGENAME',
},
{
'name': 'instagram',
'launchUrl': 'instagram://PAGENAME',
'backupUrl': 'https://www.instagram.com/PAGENAME',
}
];
#override
Widget build(BuildContext context) {
return Row(
children: [
for (Map i in icons)
IconButton(
onPressed: () async {
await canLaunch(i['launchUrl'])
? launch(
i['launchUrl'],
forceSafariVC: false,
forceWebView: false,
)
: launch(
i['backupUrl'],
forceSafariVC: false,
forceWebView: false,
);
},
splashRadius: 30.0,
iconSize: 38.0,
icon: Image.asset(
"assets/images/icons/${i['name']}.png",
color: Colors.white,
),
),
],
);
}
}
Twitter and Instagram work and open in their apps but Facebook still only opens in the web browser. I've tried tonnes of solutions on stackoverflow but to no avail. Am I missing something?
Thanks.
I've observed a limitation with the supported URLs configured in the Facebook app. In Android at least, while the Facebook app has support for facebook.com, I noticed that the Facebook app opens when it's a link to a specific post i.e. https://www.facebook.com/$profileId/posts/$postId
However, the Facebook app seems to be unable to handle direct links to the profile or page i.e. https://www.facebook.com/$profileId
If you're linking to a profile/page in Facebook, you can pin a post in the profile/page and share the link of the Facebook post as a workaround. This should successfully open the Facebook app installed on the device.

Flutter and Google Sing in: Invalid image data

I have implemented Google Authentication with FlutterFire. I use the official package to sing in users.
However, if I navigate to a page where the user profile picture is seen and try to render the GoogleUserCircleAvatarar, although the page seems to be working just fine, I get an error in the console:
════════ Exception caught by image resource service ════════════════════════════════════════════════
Exception: Invalid image data
════════════════════════════════════════════════════════════════════════════════════════════════════
On the screen, it takes a few milliseconds, to load up the picture. Before it's loaded, I can see the placeholder image (First letter of the users initials on a filled background) next to the user's name and email address (so the currentUser is loaded) which transitions to the user profile picture. As I am using the recommended Widget, I am confused how should I prevent the error from happening.
Code:
if (widget.userService.currentUser != null) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
ListTile(
leading: GoogleUserCircleAvatar(
identity: widget.userService.currentUser,
),
title: Text(widget.userService.currentUser.displayName ?? ''),
subtitle: Text(widget.userService.currentUser.email ?? ''),
),
const Text("Signed in successfully."),
RaisedButton(
child: const Text('SIGN OUT'),
onPressed: _handleSignOut,
),
],
);
} else {
...
currentUser object is created with the official API:
currentUser = await GoogleSignIn().signIn();
and my pubspec.yml:
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.14.0+1
provider: ^4.3.2+2
google_sign_in: "^4.5.1"
firebase_core: "^0.5.0+1"
firebase_auth: "^0.18.1+2"
This issue should've resolved on the latest version of the google_sign_in plugin. More details of the fix for the issue is discussed on this pull request.

How to fix 'App not found' on iOS (AppAvailability)

I am launching a flutter app (App 1) from another flutter app (App 2) on Android and it works perfectly. However, I keep getting the same error on IOS. It does not recognize the package name.
I have tried with multiple apps but is the same result, it currently just recognizes the calendar package.
pubspec.yaml file flutter_appavailability
main.dart App 2
import 'package:flutter_appavailability/flutter_appavailability.dart';
//Future void method
if (Platform.isIOS) {
_installedApps = [
{"app_name": "example", "package_name": "com.flutter.example"},
];
print(await AppAvailability.checkAvailability("com.flutter.example")); //ERROR
//Widget build
return Container {
child : Row(
...
GestureDetector(
...
onTap: () {
Scaffold.of(context).hideCurrentSnackBar();
AppAvailability.launchApp(installedApps[0].["package_name"])
.then((_) {
print("App ${installedApps[0]["app_name"]} launched!");
}).catchError((err) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(
"App ${installedApps[0]["app_name"]} not found!")));
print(err);
});
...
),
}
info.plist App 1
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
project.pbxproj App 1
PRODUCT_BUNDLE_IDENTIFIER = com.flutter.example;
Output App 2
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(, App not found com.flutter.example, null)
#0 AppAvailability.checkAvailability (package:flutter_appavailability/flutter_appavailability.dart:40:9)