最終的にはアプリ内からIOS設定画面に遷移できれば良いので。
まずは、permission_handlerをdependencies
の中に最新版を書きます。
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('設定を開く'),
),