Thanks for your help to read crash log.
Now my app has rejected over 2weeks due to this crash log.
And this crash happens when app is on launch only on iPad.
When I testd iPad simulators and iPhones, they were successfully launched.
I look into main.dart code at first based on that.
main.dart
void main() async {
await runZonedGuarded(() async {
try {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");
KakaoSdk.init(nativeAppKey: dotenv.env["KAKAO_NATIVE_APP_KEY"]);
if (Firebase.apps.isEmpty) {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
}
await Supabase.initialize(
url: dotenv.env["SUPABASE_URL"]!,
anonKey: dotenv.env["SUPABASE_ANONKEY"]!,
);
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
await StepNotification().initializeService();
FirebaseMessaging.onBackgroundMessage(messagingBackgroundHandler);
if (Platform.isAndroid) {
await AndroidAlarmManager.initialize();
await AndroidAlarmManager.periodic(
const Duration(hours: 8),
10,
stepAlarmManager,
allowWhileIdle: true,
wakeup: true,
rescheduleOnReboot: true,
);
}
} catch (e) {
// ignore: avoid_print
print("initialize app: $e");
}
if (kDebugMode) {
runApp(
const riverpod.ProviderScope(
child: OnldoccFlutterApp(),
),
);
} else {
final dnsCode = dotenv.env["SENTRY_DNS"];
await SentryFlutter.init(
(options) {
options.dsn = dnsCode;
options.attachStacktrace = true;
},
appRunner: () => runApp(
const riverpod.ProviderScope(
child: OnldoccFlutterApp(),
),
),
);
}
}, (exception, stackTrace) async {
Sentry.captureException(exception, stackTrace: stackTrace);
});
}
The only code regarding package pedometer is StepNotification().initializeService(); from main.dart.
So I moved code StepNotification().initializeService(); that initialize process to count user's step into another part of app for test and submit this app.
But that app is also rejected with same issue.
[PS]
StepNotification().initializeService() initialized flutter_background_service and after user chooses to start background service, pedometer package will be initialized.
Since I already tested as moving this to another part, I guess that this line is not causing error.
And even this line also don't initialize package pedometer at the moment when app is on launch.
I look into AppDelegate.swift code on next.
AppDelegate.swift
import UIKit
import Flutter
import flutter_background_service_ios
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
SwiftFlutterBackgroundServicePlugin.taskIdentifier = "dev.flutter.background.refresh"
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
I think when GeneratedPluginRegistrant.register(with: self) is executed, all packages request corresponding permission before didFinishLaunchingWithOptions step and it takes long time.
But It's also weird that before 2weeks, I haven't get rejected from app review with this issue even though AppDelegate.swift code is same.
I don't know why this error happens suddenly even only on iPad that iOS test team uses.
And I also check that permission 'notification' that is used from other packages is also requested before app is launched (white blank screen before UX is drawn) even when I successfully launch my app.
Why permissions are requested before app is launched even though I don't make it that.
Topic:
Community
SubTopic:
Apple Developers
Tags: