1

I have an issue with my iOS app, written on Swift 3 with Xcode.

I'm using WiFi Socket server Communication in my app to communicate with a Raspberry Pi via WiFi protocol, and UserNotification in Xcode to receive these notification sent from RPi.

The problem is when I leave the application's window and go out to home screen, it seems my app stop to listening and when my RPi send the nothifications, there is no notification on my iPhone to see.

When I test my application with Xcode simulator, it works well, on applications's window or out there on home screen, but when I test it on my iPhone device, it receive the notifications only when I rest on application's window, and stop working when I push home's button to being on home screen, or any where outside of application windows.

Maybe someone Know a solution, Thanks in advance,

Saeid S
  • 31
  • 6
  • You have used the term "notification" but I presume you aren't talking about push notifications, but rather sending a packet to a socket on your iOS device. Apps can't listen to network sockets when they are suspended. – Paulw11 Jul 26 '17 at 10:41
  • Hi Paulw11, Thanks to replay, That's means I have to use a Push Notification Method in my case? – Saeid S Jul 26 '17 at 12:34
  • @Paulw11 But I did it. – Saeid S Jul 27 '17 at 09:38
  • Did what? If you are referring to the fact that it works on the simulator, that is because apps behave differently when run from Xcode. – Paulw11 Jul 27 '17 at 10:30
  • I put it in a Background process, to be able listen to network sockets when my app is in background. – Saeid S Jul 27 '17 at 10:43

1 Answers1

0

Check the state your device is when you go on HomeScreen. Don't compare with simulator for notifications. You need to do more debugging.

The application is running in the foreground, iOS won't show a notification banner/alert. That's by design. You have to write some code to deal with the situation of your app receiving a notification while it is in the foreground.

Also, I dont think that it has anything to do with swift Check this link to get better idea Notification when in foreground iOS

cole
  • 3,147
  • 3
  • 15
  • 28