Flutter with firebase_messaging - how to custom message on permission dialog? - ios

I'm using fcm and firebase_messaging to send push notification to flutter app, and want to custom permission message when executing FirebaseMessaging().requestNotificationPermissions for ios remote notification.
Now I have permission dialog below
How to custom '"" Would Like to Send You Notifications', 'Notifications may include alerts, sounds, and icon...', and 'Don't Allow/Allow'? Does anyone any idea?
and my code
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
await _firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(
sound: true, badge: true, alert: true));
await _firebaseMessaging.onIosSettingsRegistered.listen((settings) {
debugPrint('Settings registered: $settings');
});
Here's my flutter doctor -v result
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.1 19B88, locale ja-JP)
• Flutter version 1.12.13+hotfix.5 at /usr/local/bin/flutter
• Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/shunmanabe/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.41.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.7.1
[✓] Connected device (1 available)
• iPhone 11 • 4B5E0CE0-8D25-49CC-BEBA-0BDE35991977 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• No issues found!
Thanks in advance!

first update to the latest firebase messaging dependency in your pubspec.yaml file
firebase_messaging: ^9.1.0
then create an instance of firebase messaging
final FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance;
then request for the permission
Future initialize(context) async {
if (Platform.isIOS) {
firebaseMessaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
}
}

In my case i updated the firebase dependency firebase_messaging: ^10.0.2 and replace
_fcm.requestNotificationPermissions(const IosNotificationSettings())
to
_fcm.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
but we will have to change
_fcm.configure()
as well, change it with below code.
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
RemoteNotification _notification = message.notification;
AndroidNotification _android = message.notification?.android;
});
and problem solved.

Related

flutter video_player is not working on IOS devices. Even though it works on android devices

I'm trying to use video_player in flutter to show network videos in mp4 format (https://www.heygold.com/media/reel/ThisorThat.mp4). On IOS devices it never sets _controller.value.isInitialized to true.
I'm using:
video_player: 2.4.7
Output of flutter doctor -v:
[✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-DE)
• Flutter version 3.3.9 on channel stable at /Users/casparbaumeister/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b8f7f1f986 (2 weeks ago), 2022-11-23 06:43:51 +0900
• Engine revision 8f2221fbef
• Dart version 2.18.5
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/casparbaumeister/Library/Android/sdk
• Platform android-33, build-tools 32.1.0-rc1
• Java binary at: /Users/casparbaumeister/development/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14B47b
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /Users/casparbaumeister/development/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
[✓] VS Code (version 1.73.1)
• VS Code at /Users/casparbaumeister/development/Visual Studio Code.app/Contents
• Flutter extension version 3.54.0
[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 32) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 12.6 21G115 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.94
[✓] HTTP Host Availability
• All required HTTP hosts are available
Video player page:
class ReelsPage extends StatefulWidget {
const ReelsPage({Key? key, required this.videoUrl}) : super(key: key);
final String videoUrl;
#override
_ReelsPageState createState() => _ReelsPageState();
}
class _ReelsPageState extends State<ReelsPage> {
late VideoPlayerController _controller;
#override
void initState() {
super.initState();
_controller = VideoPlayerController.network(widget.videoUrl)
..addListener(() => setState(() {}))
..setLooping(true)
..initialize().then((_) => _controller.play());
}
#override
void dispose() {
_controller.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back_ios_new_rounded, color: GOLDISH),
onPressed: () {
Navigator.of(context).pop();
},
),
automaticallyImplyLeading: true,
backgroundColor: Colors.black,
elevation: 0,
),
body:
_controller.value.isInitialized
? show video
: Loading <- never leaves this state
)
);
}
}
My info.plist includes the following lines:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
It works totally fine on android emulator and device. I know that it doest work on IOS emulators, but it also does not work on IOS devices. Every help is welcomed, also recommendations for other video player packages! Thanks in regard.

Error building iOS app with Flutter - Missing DVTPlugInCompatibilityUUID plugin

I shipped a build before the weekend everything works fine, I come back on Monday, impossible to build. I'm stuck on this for the past few days, I've been trying most of the stuff from the internet I can't seem to find a solution.
XCode build is failing specifying missing plugins (form the base Flutter install I'm guessing):
[ ] Xcode build done. 50.6s
[ ] Failed to build iOS app
[ ] Error output from Xcode build:
↳
[ ] 2021-06-10 09:23:10.255 xcodebuild[64069:7134747] [MT] PluginLoading: Required plug-in compatibility UUID F56A1938-53DE-493D-9D64-87EE6C415E4D for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CocoaPods.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2021-06-10 09:23:10.255 xcodebuild[64069:7134747] [MT] PluginLoading: Required plug-in compatibility UUID F56A1938-53DE-493D-9D64-87EE6C415E4D for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
** BUILD FAILED **
It then generates error concerning Riverpod
[+5009 ms] ../../flutter/.pub-cache/hosted/pub.dartlang.org/riverpod-0.12.4/lib/src/common.freezed.dart:121:4: Error: Getter not found: 'nullable'.
[ +2 ms] #nullable
[ ] ^^^^^^^^
[ +5 ms] ../../flutter/.pub-cache/hosted/pub.dartlang.org/riverpod-0.12.4/lib/src/common.freezed.dart:121:4: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor.
[ ] #nullable
[ ] ^
[ +1 ms] ../../flutter/.pub-cache/hosted/pub.dartlang.org/riverpod-0.12.4/lib/src/common.freezed.dart:206:4: Error: Getter not found: 'nullable'.
[ ] #nullable
[ ] ^^^^^^^^
[ ] ../../flutter/.pub-cache/hosted/pub.dartlang.org/riverpod-0.12.4/lib/src/common.freezed.dart:206:4: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor.
[ ] #nullable
[ ] ^
What I have tried so far:
flutter clean
flutter pub cache repair
Rebuilding the iOS folder
cleaning the build folder
pod update && pod install
flutter upgrade
check the use of !use_frameworks in podfile
And other configuration changes in XCode such as the script 'for install only', etc...
The only thing I see would be that the problem is coming from a package that I'm using, such as Firebase Core. They had a similar problem a year ago or so where we had to downgrade the package version in order to build and the error was similar, the problem here is that I tried to downgrade from 1.2.1 to 0.7.0 but the problem persists until it generates dependencies issues.
Same kind of issue happended with flutter_svg I think, it was due to a breaking change making it mandatory to either update flutter_svg or downgrade flutter.
Also, could it be that I have not migrated to sound null safety yet ?
If you have an idea on how to debug this, that would be very helpful. (Some stuff that I can run to have more infos regarding the error for example).
Here are my flutter doctor and pubspec files:
Flutter doctor:
[✓] Flutter (Channel stable, 2.2.1, on macOS 11.3 20E232 darwin-x64, locale en-FR)
• Flutter version 2.2.1 at /Users/Wapazz/Development/flutter
• Framework revision 02c026b03c (2 weeks ago), 2021-05-27 12:24:44 -0700
• Engine revision 0fdb562ac8
• Dart version 2.13.1
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/Wapazz/Library/Android/sdk
• Platform android-30, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (2 available)
• iPhone 11 (mobile) • 519E686E-DEDD-4859-8D8D-EA775DB7149D • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.77
• No issues found!
Pubspec.yaml:
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^2.2.2
country_code_picker: ^2.0.1
dropdown_formfield: ^0.1.3
file_picker: ^3.0.2+2
firebase_auth: ^1.4.1
firebase_core: ^1.3.0
firebase_storage: ^8.1.3
flat_segmented_control: ^0.1.0
flutter_dialogs: ^1.1.0
flutter_keyboard_visibility: ^5.0.2
flutter_radar_chart: ^0.2.0
flutter_riverpod: ^0.12.4 #^0.14.0+3
flutter_svg: ^0.22.0
google_fonts: ^2.1.0
image_picker: ^0.8.0+3
introduction_screen: ^2.1.0
modal_bottom_sheet: ^2.0.0
shimmer: ^2.0.0
video_player: ^2.1.6
youtube_player_flutter: ^8.0.0
EDIT: It seems to be coming from riverpod 0.12.4.
Updating it to the latest version generated another error but that requires code refactoring, I will update if the issue is resolved after the refactoring.
After reviewing every dependencies one by one I found the culprit.
The issue was coming from riverpod 0.12.4, updating it to the latest version fixed the issue.
In addition a refactor was necessary in order to make the app working and fix the breaking changes due to the new 0.14.0 version.
Github issue regarding riverpod
Migration guide

FlutterFire Firebase_ml_vision: PlatformException(Error 13, com.firebase.ml, Barcode engine is nil., null)

I've been using the 'firebase_ml_vision' package to scan Qr codes in an Image Stream provided by the 'camera' package. Everything was fine until the update that happened in Nov. 6. In Android, I can still scan qr codes without problems. But in iOS, i'm having the app is throwing the Exception: PlatformException(Error 13, com.firebase.ml, Barcode engine is nil., null)
I've updated my podfile with the line pod 'GoogleMLKit/BarcodeScanning', because the command 'flutter build ios' finished with an error when the Podfile had pod 'Firebase/MLVisionBarcodeModel' instead. I did because the pod update command explained that the package 'Firebase/MLVisionBarcodeModel' was deprecated, and thought it was the source of the problem.
Still the problem keeps happening.
Flutter doctor -v output:
[✓] Flutter (Channel stable, 1.22.4, on Mac OS X 10.15.6 19G73 darwin-x64, locale en-EC)
• Flutter version 1.22.4 at /Applications/flutter_sdk/jaime/flutter
• Framework revision 1aafb3a8b9 (3 weeks ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/jvasquez/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.1, Build version 12A7403
• CocoaPods version 1.10.0
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 46.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.51.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
This is the code I use to analyze the CameraImage:
static Future<List<Barcode>> detect({
#required CameraImage image,
// #required BarcodeDetector detector,
#required int imageRotation,
}) async {
var rp = List<Barcode>();
try {
BarcodeDetector detector = FirebaseVision.instance.barcodeDetector(
BarcodeDetectorOptions(
barcodeFormats: BarcodeFormat.qrCode,
)
);
var metadata = _buildMetaData(image, _rotationIntToImageRotation(imageRotation));
FirebaseVisionImage visionImage = FirebaseVisionImage.fromBytes(_concatenatePlanes(image.planes), metadata);
rp = await detector.detectInImage(visionImage);
} catch (ex) {
print("Ocurrió un error: $ex");
// UtilFunctions.escribirEnLog(
// mensaje: "$ex",
// nombreFuncion: "detect",
// tipo: 0,
// );
}
return rp;
}
static Uint8List _concatenatePlanes(List<Plane> planes) {
final WriteBuffer allBytes = WriteBuffer();
for (Plane plane in planes) {
allBytes.putUint8List(plane.bytes);
}
return allBytes.done().buffer.asUint8List();
}
The problem is, that firebase_ml_vision internally uses Firebase/MLVisionBarcodeModel and not GoogleMLKit/BarcodeScanning.
In the issue https://github.com/FirebaseExtended/flutterfire/issues/4625 another user forked the firebase_ml_vision package and adjusted it to work with GoogleMLKit/BarcodeScanning. There is also a PR for this form (https://github.com/FirebaseExtended/flutterfire/pull/5378).
It is important to mention that some functionality, especially cloud functionality, has been removed to make it work.
Therefore, this could break parts of your app where these features are missing and it is yet not a great solution.
To use the forked package include the following in your Pubspec.yaml
firebase_ml_vision:
git:
url: git://github.com/algirdasmac/flutterfire
path: packages/firebase_ml_vision

Flutter / googleapis / Gmail API send email returns 400 Bad Request

I'm facing issue using the googleapis package for Flutter/Dart. That's the code that I have...
import 'package:googleapis/gmail/v1.dart' as gMail;
import "package:googleapis_auth/auth_io.dart";
import 'package:flutter/services.dart' show rootBundle;
class Example {
ServiceAccountCredentials credentials;
Future<gMail.GmailApi> getGMailApi() async {
return gMail.GmailApi(await getGoogleClient());
}
Future<AuthClient> getGoogleClient() async {
return await clientViaServiceAccount(await getCredentials(), [
'https://www.googleapis.com/auth/drive',
'https://mail.google.com/',
]);
}
Future<ServiceAccountCredentials> getCredentials() async {
if (credentials == null) {
credentials = ServiceAccountCredentials.fromJson(
json.decode(await rootBundle.loadString('GSuiteServiceAccountInfo.json')));
}
return credentials;
}
String getBase64Email({String source}) {
List<int> bytes = utf8.encode(source);
String base64String = base64UrlEncode(bytes);
return base64StringFormatted;
}
sendEmail({
String from: 'me',
String to: 'someemail#gmail.com',
String subject: 'Some subject',
String contentType: 'text/html',
String charset: 'utf-8',
String contentTransferEncoding: 'base64',
String emailContent: '<table></table>',
}) async {
(await getGMailApi()).users.messages.send(
gMail.Message.fromJson({
'raw': getBase64Email(
source: 'From: $from\r\n'
'To: $to\r\n'
'Subject: $subject\r\n'
'Content-Type: $contentType; charset=$charset\r\n'
'Content-Transfer-Encoding: $contentTransferEncoding\r\n\r\n'
'$emailContent'), // emailContent is HTML table.
}),
from);
}
}
When I call sendEmail function I get DetailedApiRequestError(status: 400, message: Bad Request). But when I try to send the base64UrlEncoded string through the playground it works, the email is sent.
Here is my flutter doctor -v:
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17763.316], locale en-US)
• Flutter version 1.2.1 at C:\src\flutter-0.7.3\flutter
• Framework revision 8661d8aecd (3 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\bbozhidarov\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = C:\Users\bbozhidarov\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 33.3.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[!] IntelliJ IDEA Community Edition (version 2018.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.6
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[!] VS Code, 64-bit edition (version 1.30.2)
• VS Code at C:\Program Files\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)
! Doctor found issues in 2 categories.
And this is my pubspec.yaml:
name: App Mobile
description: App Mobile
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
intl: 0.15.7
cupertino_icons: 0.1.2
http: 0.11.3+17
shared_preferences: ^0.4.2
google_api_availability: 1.0.4
geolocator: 2.1.0
file_picker: 0.1.6
url_launcher: 4.0.3
flutter_calendar_carousel: 1.3.10
date_util: 0.1.4
permission_handler: 2.1.0
simple_permissions: 0.1.9
logging: 0.11.3+2
googleapis: 0.52.0+1
uuid: 2.0.0
googleapis_auth: 0.2.7
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/email_templates/dynamic_form_email_template.html
- assets/email_templates/dynamic_form_email_data_row_template.html
- GSuiteServiceAccountInfo.json
I exclude the possibility of an issue with the credentials. The same credentials/account/client is working well with DriveApi. Any help will be much appreciated. Thanks.
An old one but still relevant!
Service accounts (SA) require a real gsuite account to send emails through and which the SA can impersonate.
Solution...First ensure your SA has domain wide delegation and the authorised scope for mail sending (https://www.googleapis.com/auth/gmail.send) in Manage API Access in Admin Console. Then add the impersonated user variable, supplying an existing gsuite email address to the credentials as below:
ServiceAccountCredentials.fromJson(myJsonCredentials, impersonatedUser: "existing_gsuite_email#yourdomain")

Ads are not showing on iOS devices

In flutter, we want to use AdMob.
We set as follows.
Because there may be relationships, we also write Firebase Analytics.
[pubspec.yaml]
dependencies:
flutter:
sdk: flutter
firebase_admob: ^0.5.7
firebase_analytics: ^1.0.3
[main.dart]
void main() {
// [Analytics]
FirebaseAnalytics().logAppOpen();
// [Initialize:AdMob]
FirebaseAdMob.instance.initialize(
appId: Platform.isAndroid
? 'ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx'
: 'ca-app-pub-yyyyyyyyyyyyyyyy~yyyyyyyyyy',
);
// [Create Banner Ad:AdMob]
createBannerAd()
..load()
..show(
anchorType: AnchorType.top,
);
runApp(MyApp());
}
final MobileAdTargetingInfo targetingInfo = new MobileAdTargetingInfo(
testDevices: Const.testDevices,
keywords: <String>[
'foo',
'bar',
],
birthday: new DateTime.now(),
childDirected: true,
gender: MobileAdGender.female,
);
// [Create Banner Ad:AdMob]
BannerAd createBannerAd() {
return new BannerAd(
adUnitId: Platform.isAndroid
? 'ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX'
: 'ca-app-pub-YYYYYYYYYYYYYYYY~YYYYYYYYYY',
size: AdSize.banner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("BannerAd event $event");
},
);
}
We download the Firebase configuration file and place it in the following.
In Xcode's Target Membership, we have confirmed that it is set correctly.
/android/app/google-services.json
/ios/Runner/GoogleService-Info.plist
It is displayed normally on Android device.
However, it is not displayed on the iOS device.
The following log was output.
2018-08-29 11:21:58.147849+0900 Runner[459:115739] FirebaseAdMobPlugin <warning> [FIRApp configure]
2018-08-29 11:21:58.157062+0900 Runner[459:115880] 5.5.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more:
[abridgement]
2018-08-29 11:21:59.755279+0900 Runner[459:115739] FirebaseAdMobPlugin <warning> adView:didFailToReceiveAdWithError: Request Error: No ad to show. (MobileAd <FLTBannerAd: 0x113ef81b0> PENDING mobileAdId:ZZZZZZZZZ for: <GADBannerView: 0x113efa7b0; frame = (0 0; 320 50); clipsToBounds = YES; layer = <CALayer: 0x113efac40>>)
2018-08-29 11:21:59.757247+0900 Runner[459:115885] flutter: BannerAd event MobileAdEvent.failedToLoad
How should we implement [FIRApp configure]; in the flutter?
Is it unnecessary? We could not find it in the sample code.
Is our setting correct?
If we wait for a few more days, will mobileAdId not be pending?
$ flutter doctor -v
[✓] Flutter (Channel dev, v0.7.2, on Mac OS X 10.13.6 17G65, locale ja)
• Flutter version 0.7.2 at /Applications/flutter
• Framework revision f8a2fc7c28 (4 days ago), 2018-08-27 20:58:30 +0200
• Engine revision af42b6dc95
• Dart version 2.1.0-dev.1.0.flutter-ccb16f7282
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/xxxxx/src/android-sdks
• Android NDK at /Users/xxxxx/src/android-sdks/ndk-bundle
• Platform android-27, build-tools 27.0.3
• ANDROID_HOME = /Users/xxxxx/src/android-sdks
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
• ios-deploy 1.9.2
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 27.1.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] VS Code (version 1.25.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.17.1
[✓] Connected devices (1 available)
• iPhone 6 Plus • XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX • ios • iOS 11.4.1
• No issues found!
In parallel with this question, we also contact AdMob.
Ads will not be shown using the following app ID and ad unit ID.
ca-app-pub-3940256099942544~1458002511
ca-app-pub-3940256099942544/2934735716
We tried several terminals.
[OK] ASUS Z017DA (Android)
[OK] iPad mini
[OK] iPhone 4s
[NG] iPhone 6 Plus
[NG] iPhone SE
We tried various changes but they were ineffective. However, today "No ad to show" suddenly ceased to occur. But the ad was not displayed yet.
We thought that ads might be displayed outside the screen. When we made the following settings, the ad was displayed in the place we expected.
_bannerAd
  ..load()
  ..show(
    anchorType: AnchorType.top,
    anchorOffset: 50.0,
  );
However, in the terminal normally displayed before the change, the ad was displayed shifted downward. We could not adopt this method because we can not try all the terminals.
Next, we placed the ad under the screen.
_bannerAd
  ..load()
  ..show(
    anchorType: AnchorType.bottom,
  );
In this case, we were able to confirm that ad is displayed normally on all terminals. We wanted to place the ad on top but we gave it up.
AnchorType.top may be incorrect in some cases.
-> Privacy then
-> Adverting then
-> Limit Ad Tracking Admob is now displayed when repeating on and off.
Perhaps it is bad that DeviceID is in the same state?

Resources