Notification with sound and vibration when iphone is Locked - ios

I am currently working on an iOS app and i need some help.
I want the app to be able to notify the user about something in form a "push notification" even when the phone locked. The push notifications work fine when the phone is not locked but as soon as i lock the phone it wont give me any sound or vibration. It will only show me the visual part of the notification but it comes in completely silence. It does not even light the screen up when the notification gets pushed to the user.
I currently use
content.sound = UNNotificationSound.default()
And it works fine with sound and vibration when the phone is unlocked.
Is it because i need to do something with my settings? do i need any code to do such thing? do i need to have developer account?
Any help would make me really happy!!

3 STEPS TO HOPEFULLY RECOVER SOUND ON YOUR IPHONE FOR INCOMING NOTIFICATIONS.
Check that the ringer on the left of the phone doesn’t show an orange line – indicating sound switched off. If so, slide it to the right so only white is showing. This may have fixed it.
Swipe up from the bottom of the screen to reveal symbols, music etc. Ensure that the half moon symbol is grey and not white. If it’s white touch it to make it grey – this will switch off do not disturb. This may have fixed it.
Check your settings, Do not Disturb half moon icon, ensure that Manual is off and not showing a green on icon. If it is, touch the green icon which will make it white and switch it off. This may have fixed it.
(I hope that helps, it worked for my iphone 5C as I’d inadvertently switched on Do Not disturb as shown in step 2. above.)

Just an FYI if someone else is having this same issue. I was having the same troubles getting my notifications to come through on my phone when it was locked.
I realized the issue was I was building to my physical device which was also attached to the Apple Watch I was wearing. Since my watch is set to mirror my iPhone notifications the phone didn't play them as it expected my watch to take over when was locked. However, every time you build & run your app it takes a few minutes for your watch to recognize your app and take over the user notifications.
The solution here is to either wait 10 minutes or so after building and then try firing off a notification (which should appear on your watch) OR simple take off your watch before you build & run.

Related

How is MPChangePlaybackRateCommand triggered?

I'm playing around with the audio features in iOS, and I'm looking at MPRemoteCommandCenter's changePlaybackRateCommand. I have enabled it, given it a target, and set its supportedPlaybackRates, but I don't see any related UI showing up in control center or the lock screen. And other commands I've set up, like skip forward, skip back, like, dislike, and bookmark, show up properly.
How does a user trigger a MPChangePlaybackRateCommand on iOS?
I face this problem and when I search I get other people face the same problem here
but I found something strange when I play podcast app in apple watch I found rate icon and I change the playrate from it
I think it's not work in iPhone (iPhone 6 iOS 11 ) but appear and work in another Apple devices in my case Apple watch
in iOS example here Apple not add MPChangePlaybackRateCommand like other commands that make me sure about it's bug in iOS

Force iOS notifications to show alert buttons without swipe or force touch

I have an iOS app which plays a long (20s) audio at some schedules. The problem is if alert style is set to BANNER ( Alert style in unlocked mode in iPhone settings) then audio plays for just about 5s and then the notification hides and audio playback terminates. How can I keep alert visible until end of audio playback?
Other people have same problem:
https://forums.developer.apple.com/message/185451#185451
Although one cannot force a banner notification to stay visible for more than 5 seconds, they can make a limited amount of actions persist in the background. For example, Whatsapp or Snapchat makes your phone keep on vibrating if you receive a call after the alert is gone. I do not know if sound can be made to persist after the banner alert disappears but I'm sure Apple Developer Support can direct you to where you need to go. There phone number is: 18006332152
Hope you find a well-trodded path! Good luck my friend.

Show ios push notification for long time on phone screen

Is there any way to show a particular type(some important) of push notification for some 5-10 seconds on the iOS device screen when app is in background.
No, the time is fixed.
You cannot customize it - a push-notification should be a short message that in the best case makes the user tap it and open the app. There is actually not really a need for a longer time. Keep it short, simple and interesting and the user will react accordingly anyway. A longer time should not really make any difference other than people getting annoyed because your messages are always staying on top, blocking other messages and wasting screen space.

UILocalNotification not firing properly on iPhone when app not foregrounded

UPDATE - a warning to anyone with similar symptoms... check Do Not Disturb is not active!
I finally paid to get an app I was working on running on my iPhone instead of on the simulator.
Having done so I've spotted a strange behaviour with regards to the UILocalNotifications that I create, which are set to use the default sound UILocalNotificationDefaultSoundName, and the default timezone ([NSTimeZone defaultTimeZone]).
If the app is foregrounded then the local notification fires on time and I receive it within
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
and I create an alert view to display it.
If however I lock my phone just before a notification is expected then nothing appears on the screen, but when I press the home button to show the lock screen I can see my app's notification in the notification centre on the lock screen. No sound was played, but then again the phone didn't wake up to show the notification properly.
If however I just press the home button so the app is put in the background leaving me looking at the springboard apps then I don't see any notifications whatsoever, and again no sound is heard.
On the simulator the same code correctly fires the notification banner when looking at the app icons in the spring board, although I've never been able to hear any sounds for the notification. But as the simulator doesn't let you configure the notification centre for apps I always presumed it was perhaps set to not allow sounds. On my device sounds for this apps notifications are enabled, and i've tried it with banner and alert modes, with no joy. Very frustrating.
Has anyone experienced this, or have an idea what could be going on?
Oh the irony of this answer.. think it's time to go to bed. My iPhone thinks that too for nearly 3 hours now... My question happily describes Do Not Disturbs behaviour, which was active.. Sorry to waste everyones time!!

Lock and unlock screen - iPad

Would it be possible to lock a device screen and unlock it again? The reason I would want to do this is we have a kiosk type app and we would like to turn of the screen between certain times.
I would think a type of push notification would be needed?
Once iPad is locked you're not going to be able to unlock it programmatically, even through a push notification. Assuming these devices are always plugged in you may be better off turning off the idleTimer (which I'm assuming you already have) then invoke some sort of screen save or idle screen that displays during those hours. That way your app never allows the iPad to lock natively and you can control when clients do & don't see the content.
That brings up a design question, though... what happens if someone is present when the idle screen is up? Should you override or keep it on the idle screen? Just thinking out loud.

Resources