How to stop the LocalNotificationSound when application is opening from Device Locking screen - ios

In my application iam using UILocalNotifications, and for that notification iam setting 30 sec audio file.
Notification fired if device is UnLock state and my app is in background mode then if i click on notification bar then my app is open and notification sound is stopping. This scanario is fine.
Notification fired if device is locke state and my app is in background mode then if i drag the notification then my app is open and notification sound is not stopping. In this scanario notification sound is continuesly playing upto 30 sec.
I need to stop the notification sound when app is open.
Please help me for implementing this functionality.
Thanks in advance.

You can't, since the sound is played by iOS and not your app. Thus you have no control over it.

Related

IOS local notification custom 30 seconds sound got cut off when on screen banner went up(app in foreground) I am using voip push notification

Does anyone know is it possible to keep playing the custom notification sound after notification banner went up (app in foreground, in background it works perfectly full 30 seconds).

Why will my notification sound alert not go off when go to the lock screen on my device and re-enter the app?

I put in a notification into my app that works just right when I want it to go off. However I put a custom sound to that notification thats is about 30 seconds long. When I am at the HOME SCREEN of my device, when the the notification + sound goes off, I re-enter the app and the sound goes away. But when I am at the LOCK SCREEN, the notification goes off but when I re-enter the app it does not turn off. WHY
I guess, you can check the notification agent, whether the program allows notifications in the background.

How to play background push notification sound

I'm working on an app in which, upon receiving a push notification while in the background, should play a continuous sound until the app is opened.
Also, if the app is opened by clicking on the app icon, it should load push data.
How can I do this?

ios play continues sound when app receive push notification

Currently i am working on app in which i want to play continues sound when app receives push notification. as i know apple allow to play custom sound of length of 30 sec here is link..
but in well known app it plays continues sound in driver side when app is in back ground and driver receives order.
and another issue is of when my app is in back ground and receives push notification Rather clicking on notification if i open app by pressing app icon it does not show me data of push. it is not possible to load data when press on app icon here is link
iOS Push notification issue
but same thing is done in well known app
With iOS 7+, use application:didReceiveRemoteNotification:fetchCompletionHandler:, which is called even if your app is in the background. iOS will even launch your app in the background if it's not already running, but if the user force quits the app, it will not be re-launched. If you enable the remote-notification background mode, you can run app code when the notification arrives. If you include the audio background mode, you could initiate a sound that continues to play while app is in background.
For second question, typically, your app should query a server for updates if it's launched directly. However, you could leverage a remote notification as above, which you'd get in most cases (except if the app were force quit).

Invoke the application to play a music on receiving a push in iOS

I implemented Push notifications in iOS. I want my application to play a music (about 15sec) when I send a push message. I am currently getting the push message, and the music is being played only if the app is in the foreground.
If the app is in the background, it shows up a notification, and when i tap it, it then plays the music.
But how do I get the functionality of automatically playing the music? I think this can be done because, in iOS, Audio apps can run in the background. So I just want the music to be played when the app goes to background, and it receives a push.
Can anyone help me with this please?
Thanks,
Nithin
Yes, there are two ways to do this.
The traditional way before iOS 7 is to register for audio playing background mode and play a silent sound forever, this will keep your app running in the background for a long time until the user kills it, or it is killed due to low memory.
This way has many drawbacks, the user must launch your app once so that you can start playing the sound and every time the iPhone is shut off, the user need to relaunch your app when he turn on the iPhone.
Also this will consume a lot of battery. 20%-30% a day for an iPhone 5.
The new way after iOS 7.0 is to exploit background fetch and remote notification, you can play your sound while performing a background fetch, which has a 30 seconds running time. Also you can trigger a background fetch with a push notification.
This is an article about background fetch and push notification http://www.objc.io/issue-5/multitasking.html

Resources