CloudKit error using watchOS 3 - ios

I believe I have everything set up right, and everything works for CloudKit in the iOS Simulator, but I can't get CloudKit to work in the Watch Simulator: "Couldn't send a valid signature"
Does anyone know why this would be?
I know CloudKit works in watchOS 3 per Apple "iCloud interactions.
Starting with watchOS 3, the WatchKit extension can communicate
directly with CloudKit and other iCloud technologies."
I already did Settings > iCloud and then log in using your Apple ID
on the iOS simulator per enter link description here
In the Watch Extension, I'm calling CloudKit using CKContainer(identifier:"iCloud.com.xx.xx") per enter link description here
I double-checked Apple's doc to make sure I didn't miss something:
enter link description here
I'm accessing the same CloudKit container on the Watch that I am on
iOS, so nothing is wrong with accessibility to the data in CloudKit
The CloudKit capability with the container identifier is set
correctly in the Watch Target

According to Apple:
CloudKit usage is blocked on watchOS Simulators. Running any test will
throw a “Not Authenticated” error even though you are signed in via
the paired iOS Simulator. Workaround: Use CloudKit on paired devices
with watchOS 3 and iOS 10.
This is from the watchOS 3 release notes, but does not seem to be fixed yet. Just test on a real watch and everything will work fine.

Related

WCSession "isComplicationEnabled" always returns false in iOS 15.4

Since I've updated my test device (iPhone 12 mini) to the latest iOS version 15.4, the complications of my companion app on the watch (watchOS 8.5) do not receive any updates sent by the iOS app.
To reproduce the issue you need:
An iOS app with an watchOS companion app and at least one active complication of this app. (I can provide you access to my TestFlight app.)
The iOS app needs an active WCSession object to send update complication messages through "transferCurrentComplicationUserInfo:"
If you check the isComplicationEnabeld property, it will always return false and therefore, the complication will not be updated.
This issues only occurs since the update to iOS 15.4. Previous versions did work well.
Here is my code to transfer the updated content for the complications...
if ([self.connectivityHandler.validSession isComplicationEnabled] &&
self.connectivityHandler.validSession.remainingComplicationUserInfoTransfers > 0) {
[self.connectivityHandler transferCurrentComplicationUserInfo:[self applicationContext]];
}
The connectivityHandler is a singleton object which handles the data transfer and holds the WCSession object (validSession).
It implements the transferCurrentComplicationUserInfo method to transfer the updated content for the complication.
Since iOS 15.4, the if clause above is always false due to the isComplicationEnabled check. Before it worked correctly.
I've already tried:
Restarting devices: iPhone and watch
Resetting watch
Anyone out there with the same issue and probably a solution?
Thank's for your support!
After first tests, Apple fixed it in iOS 15.5 and watchOS 8.6.

WatchOS app not detecting companion iOS app

I am making an independent Apple Watch app (but with a companion iPhone app which is not necessary for the watch app to function.)
The app uses WatchConnectivity to sync data between devices if iPhone companion app is installed. I am able to call session.updateApplicationContext() on the iOS app and receive session(didReceiveApplicationContext) on the Watch app. But going the other way is not possible. I always get an NSError code of 7018 which means the iOS companion app is not installed.
I have made sure both watchOS and iOS app are installed in simulator (and tested on my actual devices, iPhone 11 & Watch series 5.) But getting the same failed results from watchOS -> iOS.
I noticed there is a new WCSession instance variable available for watchOS 6.0+ isCompanionAppInstalled. When I read this variable after my WCSession is activated on my watch app, it always return false.
Is there anything else I need to look out for? I am thinking maybe there is something I did wrong in all the different info.plist. But I have checked them multiple times.
my info.plist files:
In my watch app:
WKWatchKitApp is YES
WKCompanionAppBundleIdentifier is com.abc.myapp
In my watch extension:
App can run independently of companion iPhone app is YES
NSExtension
WKAppBundleIdentifier is com.abc.myapp.watchkitapp
NSExtensionPointIdentifier is com.apple.watchkit
iOS app bundle identifier is com.abc.myapp
watchOS app is com.abc.myapp.watchkitapp
watchOS app extension is com.abc.myapp.watchkitapp.watchkitextension
Is there anything else I might be overlooking?
Thank you very much for any help/insight you can offer into this.
Ok. I found a way to get rid of the error and have the watch connectivity work from watch to iPhone.
Originally I wanted the watch app to be independent so in the watch extension target in Xcode, the check box "Supports Running Without iOS App Installation" is checked. But as soon as I uncheck this box, WCSession.isCompanionAppInstalled returns true and error goes away. Syncing from watch to iPhone starts working.
So hopefully this is not intended behavior and will soon be fixed by Apple. (I filed a bug report.) But for now, I am just going to leave the independent watchOS app unchecked because I do want WatchConnectivity in case iPhone app is installed by user.
Thank you for reading and good luck with your programming.
If you have "App is only available as a standalone watchOS app" in Info.plist, delete it even if it is false. Leave only "App can run independently of companion iPhone app". Also don't forget to set "WKCompanionAppBundleIdentifier" for Watch App (not extension). At least it works on real device for me with these parameters.
This seems to be a bug. Sometimes when I start my WatchOS app, it gets WCSession.isCompanionAppInstalled = false all the time, even though the companion app on the iPhone is running, and other apps are able to communicate with the phone.
This seems to go away when I force-restart the app on the watch (press side button, then swipe the app to the left and press the big red button, then start the app again). After the restart, everything seems to work fine.
This has happened only on Testflight builds so far. If it happens in production builds, I'm going to file a bug.
My iOS app will not launch in the Simulator if I uncheck "Supports Running Without iOS App Installation".

settings bundle not working on watchOS 2

This was NOT a problem on watchOS 1, but now on watchOS 2 I cannot read the values on the watch extension.
According to Apple docs, it is possible.
According to some people on this thread, it is possible.
According to an Apple employee on this thread, it is possible.
I'm setting everything up correctly as far as I can tell:
I enabled App Groups on both iOS app and watch extension with the
same identifier.
I added Settings-Watch.bundle to the iOS app
and added the ApplicationGroupContainerIdentifier with the same
identifier to the plist
When I initialize an NSUserDefaults object with the identifier as the suite name, I cannot read values on the watch extension. I can read them on the iOS app. This happens in simulator and real device.
Please DON'T post an answer about how to do this with Watch Connectivity. It is possible to do this with just Shared App Groups on watchOS 2 without Watch Connectivity, people are able to do it, and here it is straight out of the docs:
In watchOS 2, your WatchKit extension may read the values of preferences, but you cannot write new values. Preferences in watchOS 2 are forwarded from iOS to Apple Watch, but any modifications you make are not sent back to iOS.
I've edited my answer. Previously, it spoke about the inability to use App Groups to sync data in watchOS 2, but your specific question is regarding the Settings Bundle, which still syncs from iOS to Apple Watch in watchOS 2.
I am unable to get this to work in Xcode 7.1 / 7.2 in Simulator, but it does work on a real device. From the docs:
Preferences in watchOS 2 are forwarded from iOS to Apple Watch, but any modifications you make are not sent back to iOS. In watchOS 1, WatchKit extensions have direct access to the defaults database and may read and write values.
All 3 targets should have the same App Group configured (the Watch App target here seems to be the missing component in OPs question):
My settings bundle:
Some simple interface code in InterfaceController.swift:
#IBOutlet var label: WKInterfaceLabel!
#IBAction func buttonAction() {
let sharedDefaults = NSUserDefaults.init(suiteName: "group.testSettings")
let name_preference = String(sharedDefaults?.objectForKey("name_preference"))
self.label.setText(name_preference)
}
and the final outcome:
So, it does work as expected, only not in Simulator. It seems that there is some isolation occurring between the 2 devices in Simulator, and it's a little frustrating trying to put my finger on exactly what's happening there.
This is because the apps now run native on the Apple Watch, which means they are not able to get settings from the iPhone, because the settings are not stored on the same device anymore. More info here: Unable to get values from settings bundle in watchOS 2
The new process of handling using `WCSessions be see in the sample Apple app - Lister in the below mentioned file.
https://developer.apple.com/library/ios/samplecode/Lister/Listings/Objective_C_ListerKit__WatchOS__AAPLConnectivityListsController_m.html#//apple_ref/doc/uid/TP40014701-Objective_C_ListerKit__WatchOS__AAPLConnectivityListsController_m-DontLinkElementID_57
Also, the answer mentioned in https://stackoverflow.com/a/32628105/1640786 seems to make the whole process a lot more convenient.

"Cannot connect to iTunes store" when restoring iOS In App Purchase in iOS simulator

I've looked through the many existing questions related to "Cannot connect to iTunes store" issues with iOS StoreKit and I don't think my situation is covered:
When running in the iOS Simulator, I get the "Cannot connect to iTunes store" error after restoring a previous bought in app purchase. If I hit Cancel, the popup goes away and the restore is successful.
There is no problem at all when buying the in app purchase, only when restoring.
Also, the problem only occurs on the simulator, not when testing on a real iPhone.
I'm pretty sure everything is OK, just wanted to confirm that it is just a simulator bug. Any one else seen this one?
Having researched this as much as I can, and confirmed that there are no issues when running on a device, either in sandbox mode or (since yesterday, when the IAP was approved by Apple) using a real Apple ID, I'm assuming this is a simulator bug and can be ignored.
Contrary to the answer posted by iLive below, and repeated elsewhere on SO, testing IAP on the simulator is explicitly supported by Apple, except for hosted content downloads.
UPDATE: It would appear that since iOS 7, testing IAP on the simulator is no longer properly supported. I've had it working using the non-64bit simulator, but not with the 64bit iPhone simulator. Your milage may vary. As per pix's comment below, Apple also seem to have removed mention of iOS simulator testing from their documentation.
I do not believe you can test your purchases with the simulator.
From the "In-App Purchase Programming Guide":
Store Kit does not operate in iOS Simulator. When running your application in iOS Simulator, Store Kit logs a warning if your application attempts to retrieve the payment queue. Testing the store must be done on actual devices.
If you look at this link, Apple tells you about what you should do:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/DevelopingwithStoreKit/DevelopingwithStoreKit.html
You can also check out this link: restore button for in-app purchases error
Hope this helped!
I ran into the same problem. I would get the "Cannot connect to iTunes Store". If you press Retry it will send you to the login prompt. However, if you press cancel, you will get "Restore Purchases Successful". This does seem limited to the simulator.
https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/index.html#//apple_ref/doc/uid/TP40001051-SW241
StoreKit (In-App purchases) will not work in the Simulator. 13962338
Make sure you use an account which is an sandbox user. I tried to use my personal iCloud account on Sandbox which got rejected with the same error.
As of recent (Version 8 and onwards) Xcode releases, I'd qualify the state of StoreKit in the simulator as partially implemented.
Apple officially says you need to test it on the device, however some calls seem to supported in the Simulator – at least the SKProductRequest always works flawlessly. Completing a purchase may or may not work.

In App purchase in iOS suddenly stop working ( Error code=5002 occurred )

I have integrated in-App purchase in my application successfully. I tested it properly by making test user account in itunes. My in-app purchase worked fine. But suddenly my IAP stopped working.
App can load all of the products but after entering my account credentials then transection queue undergoes state SKPaymentTransactionStateFailed and gives an error
Error Domain=SSServerErrorDomain Code=5002 "An unknown error has occurred"
It seems that the storekit does not work in the simulator any longer. I quote from storekit docs:
Note: Store Kit does not operate in iOS Simulator. When running your
application in iOS Simulator, Store Kit logs a warning if your
application attempts to retrieve the payment queue. Testing the store
must be done on actual devices.
Store Kit Docs
If you are testing on real device, make sure it is not JB.
If you are testing on simulator, make sure you are running iOS 6.0 or above, lower version of simulator doesn't work, I wasted a whole day to figure this out...
It has been stopped working on simulator. try to use it on real device. It will work fine.
I've run into the same error on iOS Simulator, but it works on my device(iPhone 3G).
The error is returned from Apple's Server, it's not under control by us.
Facing the same problem in ios 5.1 the store kit dosent work on simulator anymore you need to check it in the device.
And even after connecting to the device say you get an error code "Cannot connect to iTunes Store"
then that means that your device cannot contact the apple store and that is something which is not your fault.
To fix this, sign out of any existing account in the Settings app on your device.

Resources