Helo
Before updating Xcode to the 7.3 version I had an app with an WatchOS 2 app, The watch app would call the func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) {
and the iOS app would pick the call and insert the passed value. All was fine.
But since updating to Xcode 7.3 one issue i noticed, the func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) {
is being called twice ONLY when the iOS app is launched for the first time, if the app is running or is in the background, that function is only called once.
If I pass the values 1, 5, and 10 and the iOS app is not running, the values 1, 5, 10, 1, 5, and 10 are added. But if the app is running in any form, the values 1, 5, and 10 are added.
Any idea why?
Here is the code from the WatchOS side, I did think of that myself, but according to my tests they are only called once. I have done many tests, and this is only happening when the iOS app is launched, not when its ruling in the background.
@IBAction func ConfirmButtonPressed() {
let applicationDict = ["Amount out": self.AmountText ]// Create a dict of application data
//applicationDict = ["status": "0" ]// Create a dict of application data
WCSession.defaultSession().transferUserInfo(applicationDict)
}
Here is the iOS app code from the app delegate
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if (WCSession.isSupported()) {
print("xyz3")
session = WCSession.defaultSession()
session.delegate = self
session.activateSession()
}
..........
func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) {
var status = false
var AmountUILabel = ""
status = false
AmountUILabel = userInfo["Amount out"] as! String
print(userInfo["Amount out"] )
let i = NSString (string: AmountUILabel ).doubleValue
let when = NSDate()
let list :[AnyObject] = controller.viewControllers!
let j = list[1].topViewController as! AllEntriesTableViewController
j.AddAmount(i , date: when, what: "---", status: status)
}