Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having issue how to add app tracking transparency to my app #10

Closed
7oda187 opened this issue Apr 29, 2021 · 3 comments
Closed

Having issue how to add app tracking transparency to my app #10

7oda187 opened this issue Apr 29, 2021 · 3 comments

Comments

@7oda187
Copy link

7oda187 commented Apr 29, 2021

Hello Team,

Kindly need your support on how can add app_tracking_transparency to my app.
As i'm using flutter for my project. everything is working normally but having difficulty with this one.

Can you please guide me on how to implement this in my app?

Attached my main.dart code below:

`import 'dart:io' show HttpClient;

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pedantic/pedantic.dart';
import 'package:provider/provider.dart';
import 'package:responsive_builder/responsive_builder.dart';

import 'app.dart';
import 'common/config.dart';
import 'common/constants.dart';
import 'common/firebase_services.dart';
import 'common/tools.dart';
import 'env.dart';
// import 'frameworks/vendor_admin/vendor_admin_app.dart';

Future main() async {
WidgetsFlutterBinding.ensureInitialized();
Configurations().setConfigurationValues(environment);

GestureBinding.instance.resamplingEnabled = true;

Provider.debugCheckInvalidValueType = null;
printLog('[main] ============== main.dart START ==============');

if (!kIsWeb) {
/// enable network traffic logging
HttpClient.enableTimelineLogging = true;

unawaited(SystemChrome.setPreferredOrientations(
    [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]));
SystemChrome.setSystemUIOverlayStyle(
  SystemUiOverlayStyle.dark.copyWith(statusBarColor: Colors.transparent),
);

}

// Initialize Firebase due to version 0.5.0+ requires to
if (!isWindow) {
await GmsTools().checkGmsAvailability();
await FirebaseServices().init();

if (FirebaseServices().isAvailable) {
  // await Configurations().loadRemoteConfig();
  printLog('[main] Initialize Firebase successfully');
}

}

// if (serverConfig['type'] == 'vendorAdmin') {
// return runApp(const VendorAdminApp());
// }

ResponsiveSizingConfig.instance.setCustomBreakpoints(
const ScreenBreakpoints(desktop: 900, tablet: 600, watch: 100));
runApp(App());
}
`

Appreciate your kind support.

@untp
Copy link
Contributor

untp commented Apr 30, 2021

There are many ways to use this package. You can show dialog after app launch, after onboarding finished, or before first ad load. You can also show an explainer dialog before system dialog. Check README and example for integrating this package.

Also, I see you are using if (!kIsWeb), therefore you are targeting both web and iOS. So you need to wrap this package's method calls with !kIsWeb like:

if (!kIsWeb) {
  await AppTrackingTransparency.requestTrackingAuthorization();
}

That's it. I don't know which problem you are getting. Can you explain in more detail the difficulties you are having?

@7oda187
Copy link
Author

7oda187 commented Apr 30, 2021

There are many ways to use this package. You can show dialog after app launch, after onboarding finished, or before first ad load. You can also show an explainer dialog before system dialog. Check README and example for integrating this package.

Also, I see you are using if (!kIsWeb), therefore you are targeting both web and iOS. So you need to wrap this package's method calls with !kIsWeb like:

if (!kIsWeb) {
  await AppTrackingTransparency.requestTrackingAuthorization();
}

That's it. I don't know which problem you are getting. Can you explain in more detail the difficulties you are having?

Dear Untp,

Thank you for your reply.

Actually i want the message appear to the user after onboarding finished,

Can you help me with the code writing for it.

@untp
Copy link
Contributor

untp commented Apr 30, 2021

It depends on what package you are using for onboarding. For example if you use fancy_on_boarding, you can show the dialog when the user taps the done button:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: FancyOnBoarding(
        ...
        onDoneButtonPressed: () {
          try {
            // If the system can show an authorization request dialog
            if (await AppTrackingTransparency.trackingAuthorizationStatus ==
                TrackingStatus.notDetermined) {
              // Show a custom explainer dialog before the system dialog
              if (await showCustomTrackingDialog(context)) {
                // Wait for dialog popping animation
                await Future.delayed(const Duration(milliseconds: 200));
                // Request system's tracking authorization dialog
                await AppTrackingTransparency.requestTrackingAuthorization();
              }
            }
          } on PlatformException {
            // Unexpected exception was thrown
          }
          Navigator.of(context).pushReplacementNamed('/main');
        }
      ),
    );
  }

For introduction_screen, you can add the dialog request to onDone callback. Almost all onboarding packages, provide an onDone callback. If you are using a custom solution for onboarding, you can add the dialog request before navigating to the main page.

@deniza deniza closed this as completed Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants