in my application, i need to put a switch for notification settings. I put a sound switch so when a switch is off and I will get a notification, the sound will not come. this is working because when a sound switch is off I am sending JSON without sound. Now I want same functionality for vibration. when vibration switch is on my device should vibrate when I receive a push notification and it should not vibrate when my vibration switch is off.
Asked
Active
Viewed 91 times
0
-
try this solutions https://stackoverflow.com/questions/4345559/vibrate-in-push-notification – Chirag Shah Dec 28 '17 at 05:37
-
Put to audio files , one is sound one is silent audio file , send empty file name in notification when you dont need to play sound.dont need to add any check or condition – Matloob Hasnain Dec 28 '17 at 05:39
-
1@chiragshah Thanks, it seems to works for me. but in one scenario I only need sound and no vibration is there any solutions for that? – Govind Rakholiya Dec 28 '17 at 07:17
-
@matloobHasnain how can I handle when I only need sound no vibration – Govind Rakholiya Dec 28 '17 at 07:24
-
sound file only – Matloob Hasnain Dec 28 '17 at 07:30
-
@GovindRakholiya if you want sound then in sound parameter put the sound file otherwise used vibration file – Chirag Shah Dec 28 '17 at 08:56
1 Answers
0
First of all import these:
import UIKit
import AudioToolbox
Then write this code in switch action for vibration:
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

User511
- 1,456
- 10
- 28