benjamindean / flutter_vibration

Handle vibration on iOS and Android in Flutter apps
217 stars 67 forks source link

IOS didn't work #54

Open byferdi42 opened 3 years ago

byferdi42 commented 3 years ago

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

benjamindean commented 3 years ago

Can you post any code examples?

byferdi42 commented 3 years ago

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(); } }

benjamindean commented 3 years ago

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

mano3891 commented 3 years ago

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 commented 3 years ago

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!

byferdi42 commented 3 years ago

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 :(

nohli commented 3 years ago

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.

publicBenz commented 9 months ago

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

1.8.1

iOS16.7