2

I am trying to implement an iOS app, where the user can receive push notification/alert for one minute with sound similar to Skype's incoming call alert. But it is not a VoIP app. It is for emergency alerts, so I want to push some text but for a longer period of time unlike normal push notifications.

Thanks

Ahmed Nawar
  • 1,315
  • 2
  • 9
  • 16

2 Answers2

1

I would follow a different approach.

send a Silent notification so no sound will be played with the notification. build your app to be able to play music in background and once the silent notification is received, initiate the sound to be in a loop. play the sound and wait for the user to interact with the app or stop it after X amount of time.

at least I would start with this approach and tweak it to make it the way I want.

Crisredfi
  • 56
  • 2
  • Thanks. Can you execute code based on a push notification even if the user didn't tap on it? – Ahmed Nawar Sep 22 '14 at 13:42
  • sure. silent push notification let you do that. here is a thread that talks about this. http://stackoverflow.com/questions/11861117/can-push-notifications-be-used-to-run-code-without-notifying-user – Crisredfi Sep 22 '14 at 13:59
  • Awesome. Thanks. Just to make sure that I understand correctly, this also works if the app is not running at all, right? – Ahmed Nawar Sep 22 '14 at 19:17
  • yep. notifications will wake up your app even if its not running in background. – Crisredfi Sep 23 '14 at 07:36
  • Did you implement the way you want? Because i couldn't make it workable. Do you have any idea about iOS PushKit? – Asif Bilal Dec 19 '16 at 14:25
0

One more way you can try is if you want the notification to appear longer,

  1. Consume the push notification
  2. Display it in your own new window/view -(fake push notification appearance) and keep playing the sound in the same view where you show push notification and stop sound when the user taps on the view showing push.
UIResponder
  • 785
  • 9
  • 15
  • This will not work when your app is on background. You can't present your views from background to apple home screen or another apps. – Jakub Průša Mar 07 '16 at 07:11
  • You will get a call back in - didReciveRemoteNotification - doesn't matter if you app is background or foreground. in this method consume the userinfo of notification and present – UIResponder Mar 07 '16 at 07:23
  • Yes of course, but how after present your custom view, in background state? Or missing I am something? :) – Jakub Průša Mar 07 '16 at 07:45