0
0

More than 1 year has passed since last update.

FlutterのiOSシュミレーターで設定画面に遷移させる

Last updated at Posted at 2022-07-06

最終的にはアプリ内からIOS設定画面に遷移できれば良いので。
スクリーンショット 2022-07-06 12.16.20.png
まずは、permission_handlerdependenciesの中に最新版を書きます。

pubspec.yaml
dependencies:
  permission_handler: ^XX.X.X <-latest

flutter pub getする前に下記2行をInfo.plist内に追記と↓
<key>PermissionGroupNotification</key>    <string>通知をするため</string>

ios/Runner/Info.plist
~省略~
<plist version="1.0">
<dict>
	<key>PermissionGroupNotification</key>   
    <string>通知をするため</string>
	<key>CFBundleDevelopmentRegion</key>
~省略~

Podfile内にも下記を追記します。

~省略~
flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
              '$(inherited)',

      'PERMISSION_NOTIFICATIONS=1',
      ]

    end

  end
end

一度、

flutter clean

してから

flutter pub get

します。

cd ios

あとはiosフォルダに移動してpod installすれば使えるようになります。

pod install

使用したいdartファイルでインポートしてきてopenAppSettings関数を呼べば遷移できます。

hoge.dart
import 'package:permission_handler/permission_handler.dart';

TextButton(
  onPressed: () async {
    openAppSettings();
  },
  style: TextButton.styleFrom(
    primary: Colors.blue,
  ),
  child: Text('設定を開く'),
),
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0