Post

Replies

Boosts

Views

Activity

How to get the crash logs and reports in watch os apps
Hi, I have developed a watch app and has been deployed to testflight. Since then when the testers download and install the app after a certain process (assumes after an api call) the watch app gets crashed. But I also installed the same app and tried but its working fine on my watch. Both the tester's and my watch is of same kind and runs the same watchOS versions. I tried repairing, resetting my phone and my watch but no luck. I was unable to recreate the issue. So what I need now is to integrate some sort of crashlytics to my watch OS app. Is it by default available, or should i use some sort of SDK? Is it possible like installing a third party app and get the crash logs without adding a new release to the testflight? Please can someone guide me through this. Thanks in advance
0
0
479
Nov ’21
The network connection is lost
I am getting an error time to time, and irritating error Optional(Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=-4, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <BB6171AF-E4AF-49F2-ACEE-A2CDA67B825E>.<3>, _NSURLErrorRelatedURLSessionTaskErrorKey=(   "LocalDataTask <BB6171AF-E4AF-49F2-ACEE-A2CDA67B825E>.<3>",   "LocalDataPDTask <BB6171AF-E4AF-49F2-ACEE-A2CDA67B825E>.<3>",   "LocalDataTask <BB6171AF-E4AF-49F2-ACEE-A2CDA67B825E>.<3>" ), NSLocalizedDescription=The network connection was lost., _kCFStreamErrorDomainKey=4, NSErrorFailingURLStringKey=https://url, NSErrorFailingURLKey=https://url}) Why am I getting this error? I have a method which handles api calls called retry() and depending on the status i need to refresh my token and then retry the same request again. So what I have done is check whether the response after excuting the initial api call is SOMECODE and then refresh the access token if it is calling the refreshAccessToken method and depending on its response if it's a success then I recursively call the same function retry() again and excute the logic. It works fine sometimes and sometimes it gives the above error if responseDescDisplay == "SOMECODE"{      refreshAccessToken(){ isSuccess,isFailed, errCode in       if isSuccess {        retry(urlString: urlString, method: method, requestBody: requestBody, completionHandler: completionHandler)        retry = true;       }else{        if !retry {         if errCode.isEmpty {          completionHandler(nil,nil,"OHNO");         }else{          completionHandler(nil,nil,"ERROR");         }                  }       } My refresh access token method looks something like this, URLSession.shared.dataTask(with: tokenRegenerateRequest) { data, res, err in   print("EROR: ", err)   print("DARA: ", data)   if err != nil {    print("IN HERE")    completionHandler(false, false, "INTERNAL_SERVER_ERROR");   }   guard let data = data, err == nil else {return}   guard let httpResponse = res as? HTTPURLResponse else {    return   }           //    print("REGENRATING TOKEN \(httpResponse.statusCode) \(res)");   if httpResponse.statusCode == 200 {    if !data.isEmpty {     do {      let decodedResponse = try! JSONDecoder().decode(RefreshTokenResponse.self, from: data);      print("ACCESS TOKEN REGENRATE REQUEST: ", decodedResponse)      if !decodedResponse.accessToken.isEmpty && !decodedResponse.refreshToken.isEmpty {               completionHandler(true,false, "")      } else {       print("HERE1")       completionHandler(false,true,"")      }     }catch{      print("HERE2")      completionHandler(false,true,"")     }    } else {     print("HERE3")     completionHandler(false,true,"")    }   }else {    print("HERE4", httpResponse.statusCode)    completionHandler(false,true,"")   }      }.resume() What am i doing wrong. Why do I keep getting the above error?
0
0
480
Oct ’21
How to decrypt in swift using CommonCrypto
I am building an IOS app and it communicates with the JS. So the communication between the two ends must be encrypted. So my main intention is to encrypt from Javascript side and send it to the IOS app mobile end, and the mobile app should decrypt the data. This is how I have done on Javascript side and it works fine as expected, const key = CryptoJS.enc.Utf8.parse("1111111111111111"); const iv = CryptoJS.enc.Utf8.parse("ui09ji884uh88984"); var encrypted = CryptoJS.AES.encrypt("Hello world",key, { mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7, iv: iv }); console.log("Encrypted data ="+encrypted); The issue is how I can decrypt this encrypted data in swift using CommonCrypto. Since this is plain base64 text how can we feed it to decryption? The code I have done so far in swift is posted below, func testCrypt(data data:[UInt8], keyData:[UInt8], ivData:[UInt8], operation:Int) -> [UInt8]? { let cryptLength = size_t(data.count+kCCBlockSizeAES128) var cryptData = [UInt8](repeating: 0, count:cryptLength) let keyLength = size_t(kCCKeySizeAES128) let algoritm: CCAlgorithm = UInt32(kCCAlgorithmAES128) let options: CCOptions = UInt32(kCCOptionPKCS7Padding) var numBytesEncrypted :size_t = 0 let cryptStatus = CCCrypt(CCOperation(operation), algoritm, options, keyData, keyLength, ivData, data, data.count, &cryptData, cryptLength, &numBytesEncrypted) if UInt32(cryptStatus) == UInt32(kCCSuccess) { // cryptData.remove cryptData.removeSubrange(numBytesEncrypted..<cryptData.count) } else { print("Error: \(cryptStatus)") } return cryptData; } This is the way I have called the above method, let message    = "HEY" let messageData  = Array(message.utf8) let keyData    = Array("1111111111111111".utf8) let ivData    = Array("ui09ji884uh88984".utf8)            let str = "SJeOvypKWad9GzUD2GHRig==" let buf: [UInt8] = Array(str.utf8)           print("BUFF: ",buf)             let encryptedData = testCrypt(data:messageData,  keyData:keyData, ivData:ivData, operation:kCCEncrypt)!          let decryptedData = testCrypt(data:buf, keyData:keyData, ivData:ivData, operation:kCCDecrypt)! var decrypted   = String(bytes:decryptedData, encoding:String.Encoding.utf8)! This works fine if we do both the encryption and decryption and passing the encrypted byte array for decryption. But when I try to convert the encrypted text in to a byte array and passing it to it, an exception occurs. And also the one which I convert (eg: buf) and which the testCrypt returns after encrypting (eg: encryptedData) isn't similar. Please can anyone elaborate this and provide a solution will be greatly appreciated.
1
0
2.9k
Oct ’21
Is it safe to pass data via watchConnectivity
Hi, I am developing a dependant watch app and need to pass some data from the phone to watch and vice versa to sync up(Imagine login credentials). So is it secure to pass data as plain text from the mobile to watch app and vice versa? Can hackers or middleman can listen and gain the data within the communication process? Or is the data encrypted by any means default by apple?
1
0
609
Oct ’21
isCompanionAppInstalled isn't updating
Hi, I am building a companion watch os app and I want to check before sending a message from watch to phone, whether the app is installed on phone. But whenever I check for whether the companion app is installed it always returns true, even when I uninstall the mobile application (Please note this is a dependant app). Next I found out that in independant apps, watchconnectivity supports isCompanionAppInstalled, and then I ticked the extension to run as independant and then used the isCompanionAppInstalled. It always returns false regardless of whether the app is installed or not? I am not sure why this not working for either of the above 2 scenarios? How can we find whether the companion IOS app is installed in the device from the watch?
1
0
1.3k
Oct ’21
How much time will it take approximately to receive a reply after a message is sent in WCSession
Hi, I am currently building a companion watch application and I use wcsession to exchanges some data within the IOS app and watchOS app. I want to know how much time maximum it would take to send a message and receive a response? Because we can't hold the user infinitely until the watch receives the necessary data? So is it handled from the wcsession itself, like sending out a timeout exception or is it necessary to handle from the developer end? If it is can anyone add a possible solution. Thanks.
1
0
640
Oct ’21
Watch app cannot make direct requests without having the iPhone wifi on
Hey, I am building a watch only application which contains some api requests to be integrated such that data should be shown. I am using the apple watch se and I have turned on the wifi in the watch. But when I am making an api request for example, Guess I am trying to display a list and inorder to obtain that list I am required to make an api call from the watch app itself and I have written the required code. There are 4 different scenarios I tested and these are the results IPhone wifi on, watch wifi on - works IPhone wifi on, watch wifi off - works IPhone wifi off, watch wifi on - doesn't work Both switched off - doesn't work 1,2,4 can be accepted. But I am not sure why 3 is not working. I tested the app store in the watch as well following the above 4 scenarios and still the results are same. So my hypothesis is that it's the behavior of the watch. But i am not sure the reason why 3. is not working since I am making a standalone app and the watch supports wifi or internet connection why can't we directly pull data via the watch internet connectivity? Please someone who can elaborate the reason will be greatly appreciated. Thanks in advance!
3
1
2.0k
Sep ’21