2

I'm using MobileFirst Platform 7.1 with Paho MQTT (Internet of Things), I'm trying to implement a Hybrid Application with mqtt for Android and iOS.

I have tested the app in Android and it is working as expected, when it is in the foreground and background,

While in iOS, it does not work as expected. It works correctly in the foreground, but not in the background. I was testing using the iPhone Simulator of XCode and iPhone 6.

I found a project which implemented with MobileFirst and MQTT. from https://developer.ibm.com/mobilefirstplatform/documentation/integration/mq-telemetry-transport/

i am just adding host and port number and adding android,ios environment.but same problem facing android working iOS not.

at this moment what can i do ?

UPDATE:

in iOS, it works correctly foreground.but when i send background the "MQTT client" connection lost form broker.

this method fire :

this.client.onConnectionLost = function() {
        alert("Connection lost!");
    };

on the other hand , android , windows it work perfectly for foreground and background

For example :

I have a room there have a PIR sensor. it work like publisher . my application user is a subscriber .

when user out the room that that time she open application,subscribe and send application background.

anytime someone entire the room that time , she will be get a notification.

Nazmul Hasan
  • 10,130
  • 7
  • 50
  • 73
  • You did not explain the specific actual problem that you're experiencing though. The sample application expects you to be in the foreground, not background. – Idan Adar Feb 18 '16 at 20:38
  • @IdanAdar thousand of apologize, could you check the updated section?. – Nazmul Hasan Feb 19 '16 at 01:11
  • The link provided in the answer is about the only definitive answer you will get from Apple without submitting your app and seeing if they accept it or not. – hardillb Mar 13 '16 at 12:38
  • I can not found at least one way to mange it for hybrid application ,tried to several way ,failed and mange it easily for native application MQTT iOS background. – Nazmul Hasan Mar 13 '16 at 13:13

2 Answers2

1

Details on how to run in the background on iOS can be found here. This link also lists the actions that Apple allows to run in the background, if your app does not meet those criteria then it is likely to get bumped from the app store.

The list also shows which UIBackgroundModes to place in your Info.plist to flag that your app needs background access.

hardillb
  • 54,545
  • 11
  • 67
  • 105
  • The answe is correct. iOS apps by default will not work in the background - network connections will drop. You need to enable it to work in the background. – Idan Adar Feb 19 '16 at 05:20
  • @IdanAdar i know that !, how can i enable to work in the background in hybrid MobileFirst application . – Nazmul Hasan Feb 19 '16 at 07:57
  • Once you open the project in Xcode, change the property in the info.plist as hardillb mentioned. – Idan Adar Feb 19 '16 at 08:19
  • @IdanAdar hardillb also mentioned "if your app does not meet those criteria then it is likely to get bumped from the app store" .what you suggest . change the property ? – Nazmul Hasan Feb 19 '16 at 08:40
  • That is not something mobilefirst can promise you. this is between you and Apple. – Idan Adar Feb 19 '16 at 08:44
0

I can not found at least one way to mange it for hybrid application ,tried with several way ,failed and mange it easily for native application MQTT iOS background.

Todos

Plan support for new platforms (iOS, Windows Phone)

Add background service support in Android version

more check this link https://github.com/arcoirislabs/cordova-plugin-mqtt

Nazmul Hasan
  • 10,130
  • 7
  • 50
  • 73