LoginSignup
1
1

More than 5 years have passed since last update.

XamarinでiOSのシステム音・バイブ機能を呼び出す

Posted at

DependencyService使ってiOS側に書くしかないです

[assembly: Dependency(typeof(DeviceFunction))]
namespace hoge.iOS
{
    public class DeviceFunction : IDeviceFunction
    {
        private SystemSound _sound = null;
        private SystemSound _vibe = null;

        public void PlayVibrate()
        {
            if (_vibe == null)
            {
                _vibe = new SystemSound(1519);
            }
            _vibe.PlaySystemSound(); // サウンドと言いつつ振動する
        }

        public void PlayGoSound()
        {
            if (_sound == null)
            {
                _sound = new SystemSound(1104);
            }
            _sound.PlaySystemSound();
        }
}

少し古い記事ですがID番号をまとめてくれてる記事ありました

1
1
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
1
1