flutter_vibration icon indicating copy to clipboard operation
flutter_vibration copied to clipboard

IOS didn't work

Open byferdi42 opened this issue 4 years ago • 8 comments

I have no problem on android but tried on 2 devices in ios it didn't work

He's working on a sample project on iOS. Doesn't work on my project I have repeatedly checked if everything is the same.

I would be glad if you could help about the problem.

thanks in advance

byferdi42 avatar Dec 10 '20 13:12 byferdi42

Can you post any code examples?

benjamindean avatar Dec 10 '20 13:12 benjamindean

of course

import 'dart:async';

import 'package:fluttertoast/fluttertoast.dart'; import 'package:vibration/vibration.dart';

class VibrationManager { static VibrationManager _instance; bool hasVibrator = false;

VibrationManager._init();

static VibrationManager get instance { if (_instance == null) { _instance = VibrationManager._init(); } return _instance; }

Future init() async { //await Future.delayed(Duration(milliseconds: 500)); hasVibrator = await Vibration.hasVibrator(); }

void vibrate({ int duration = 500, List pattern = const [], int repeat = -1, List intensities = const [], int amplitude = -1, }) { if (this.hasVibrator) { Vibration.vibrate( duration: duration, pattern: pattern, repeat: repeat, intensities: intensities, amplitude: amplitude, ); } else { Fluttertoast.showToast( msg: "Telefonunuz Titreşimleri Desteklemiyor Bir Sonraki Güncellemeyi Bekleyebilirsiniz.", ); } }

void cancel() { Vibration.cancel(); } }

byferdi42 avatar Dec 11 '20 08:12 byferdi42

If you just need the device to vibrate, try without any arguments :.vibrate(). Also, hasVibrator is a Future, so it has to be awaited.

benjamindean avatar Dec 11 '20 10:12 benjamindean

Yeah same for me too, I did try the await and I can see it can vibrate but then the iPhone doesn't vibrate when I do Vibrations.vibrate().

My test device is an iPhone XR running iOS 14.2.

mano3891 avatar Dec 11 '20 16:12 mano3891

Yeah same for me too, I did try the await and I can see it can vibrate but then the iPhone doesn't vibrate when I do Vibrations.vibrate().

My test device is an iPhone XR running iOS 14.2.

It is working! Sorry I had "Vibrate on Ring" option disabled in "Sound & Haptics". Once I enabled that, it started vibrating!

mano3891 avatar Dec 11 '20 20:12 mano3891

If you just need the device to vibrate, try without any arguments :.vibrate(). Also, hasVibrator is a Future, so it has to be awaited.

Yeah same for me too, I did try the await and I can see it can vibrate but then the iPhone doesn't vibrate when I do Vibrations.vibrate(). My test device is an iPhone XR running iOS 14.2.

It is working! Sorry I had "Vibrate on Ring" option disabled in "Sound & Haptics". Once I enabled that, it started vibrating!

I tried both but it didn't work :(

byferdi42 avatar Dec 15 '20 13:12 byferdi42

Another package https://pub.dev/packages/flutter_vibrate also vibrates with 'Vibrate on Ring' disabled.

Would be really nice to have this feature in this package, too.

nohli avatar Jan 09 '21 13:01 nohli

It works for me after turn all of 'Setting->Sounds&Haptics->RING/SILENT MODE SWITCH' on. #1.8.1 iOS16.7

publicBenz avatar Oct 10 '23 07:10 publicBenz