iOS iCloud not restoring after deleting App - icloud

I'm trying to get the key value store in iCloud to work and I'm running into an odd problem.
I store data using:
[[NSUbiquitousKeyValueStore defaultStore] setObject:#"SomeValue" forKey:#"SomeKey"];
[[NSUbiquitousKeyValueStore defaultStore] synchronize];
I read the data using:
someValue = [[NSUbiquitousKeyValueStore defaultStore] objectForKey:#"SomeKey"];
This all works great when I start and stop the App. Values are stored and I see the values being read. Everything is fine.
Then I delete the App from my device and load it again (via xcode). Now, I don't see any data come down from the cloud.
Isn't one of the main points of iCloud that you can delete an App and then recover data (in my case, game save state)?
Why does deleting my App and reinstall it (running it in xcode) cause all the iCloud data to vanish?
I am running this on the device, not the simulator. I've tried it on iOS 5 and iOS 6 with the same results.
NSUbiquitousKeyValueStore seems really simple to use, but I'm clearly doing something wrong.

First, try synchronizing before you read the data to make sure the latest updates have come in from iCloud.
Do you have another device on which you can test? If so, run the writing code on one device and then run the reading code on another device. It could be that even though you're using NSUbiquitiousKeyValueStore, it isn't actually syncing when you think it is. The reason that it would work on your device is that the key value store is available locally, but not in iCloud. So when you delete your app you're deleting the local (and also your only) copy of the data.

I found you need to register for the NSUbiquitousKeyValueStoreDidChangeExternallyNotification notification to make the sync work. It wouldn't persist data after a reinstall without it.
- (void)iCloudKeyStateChanged:(NSNotification*)n {
}
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
...
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(iCloudKeyStateChanged:) name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification object:nil];
}

Related

How to access frames of RTCVideoRenderer ? (ios)

I try to access frames of RTCVideoRenderer without success, can you help me please ?
I noticed that there is a "didCaptureVideoFrame" method in RTCVideoCapturerDelegate, but not in RTCVideoViewDelegate.
I have never done objc, I added a method in RTCVideoViewDelegate to get frames (bellow "didChangeVideoSize"), but it do not get fired, I guess it do not work like that.
I am able to access frames from the remote using Android using the "onFrame" of VideoSink, I thought it would be that easy using ios.
PS: To add the method, I took the framework from the pod and put it in the project, because I noticed that when you modify a pod, changes do not apply.
Here is the line I added :
- (void)videoView:(id<RTCVideoRenderer>)videoView didRenderVideoFrame:(RTCVideoFrame *)frame;
I will now try to compile the library with the changes I want.
EDIT:
I am now compiling the library, I noticed the need to change several files to be able to access frames, it will not be done just by adding 10 lines.
Solved thanks to this : How to get frame data in AppRTC iOS app for video modifications?
I used this line instead (because names changed since) :
#property(atomic, strong) RTCVideoFrame* videoFrame;
I wanted a "onFrame" like VideoSink on Android, but it will be ok for now.

Can't use the Virtual Stick even though isVirtualStickControlModeAvailable returns true

I am having a problem with the virtual sticks, the following is the problem.
The Virtual sticks fire the notification, the listener sends the proper values to the roll, pitch, yaw and throttle, the isVirtualStickControlModeAvailable method from the sdk returns true, when it returns true I use the command from the flight controller send which returns the completion error nil, which means I can not do anything else from there, actually I do not need to do anything else. The virtual Sticks are working in a timer as the sample simulator from DJI.
What can I do in my app?
- Take off
- Land
- Give control back and forward to the RC
None of the list above brings me errors, including the process of the virtualStick.
What else did I try?
- Run the sample simulator app from DJI, linked above.
- Run the sample app on Android
- Run using the Bridge APP (Thats how i know the values are being passed correctly, even though i added labels on screen to debug without the Bridge APP)
- Update firmware from the aircraft and RC to the latest
- Sample simulator IOS
- Went back to previous working commits and branches on git
None of the things I have tried above worked.
Curious Stuf:
- The virtual Sticks worked fine till Yesterday, and before yesterday, in many diferent branches and commits in multiple branches.
- Reseting the Remote control, Executing Manual Linking and Linking through the DJI Official APP, and clearing the cache, memory sdcard made it work on Simulator Assistent DJI (Latest version) with a lot of interference, in the Sample apps on Android and IOS, and on my Swift 3 application. Then it had some interference, I tested outside on the real Aircraft, it was working beautifully.
- Today, the same thing happens. Already did the whole testing above mentioned, the Android sample apps, IOS Sample Apps, the Simulator, Bridge, My application, Reset remote etc. And it does not work.
I would be really glad if someone could point me out the problem.
On this thread I explain partially the problem and what I have tried. http://forum.dev.dji.com/forum.php?mod=viewthread&tid=32729
Already sent an email to DJI support, still no answer.
Aircraft: Phanton 4.
I have found the problem, it was the aircraft, I could get hands in a new aircraft, just pluged to the new RC linked to the new Aircraft, it worked with no problem.
Then I tested the new RC linking to the old aircraft, It did not work, then the Old RC with linked to the new Aircraft, it worked.
Glad you found the fix.
It might be worth it to update the firmware of the old aircraft.
You can do so using the DJIGo app or DJI Assistant software for desktop.

How can I replace an exising file into the assets folder with a refresh stuff?

I'm develepping a BB10 mobile application using the momentics IDE.
I'm trying to save somes images coming from server into the "assets/images" folder using the Qt QFile object (you can see the code below) :
m_file = new QFile(argSavingFilePath);
if (m_file->exists()) {
m_file->remove();
}
m_file->open(QIODevice::WriteOnly);
m_file->write(argDataLoaded);
m_file->close();
m_file->~QFile();
It seems that is working but even if I exit out of the screen in question with the back button and then return it still doesn't show the latest image. It only works when I exit the app completely and launch a new instance.
According to this forum [link], they said :
"What's happening is that when you first load the image it gets read from the file system and then cached in memory. The app never goes back to re-read the image from the file. You would have to initiate that yourself."
How should I initiate the cashed memory myself ? is this the only solution ?
Whether the data is cached in memory or not is immaterial. The asset directory, in fact everything below and including the app directory is protected and immutable.
If you want to store data from a server the place to put it would be in data if you want it to persist, or tmp if not. Data in the tmp director is subject to removal by the OS when storage is needed for other things.
See: https://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/file_system.html

does WMI cache data in requests?

I've tried the Win32_DesktopMonitor and checked the "Availability", but the value returned is always 3 (powered on), even when the monitor is physically turned off.
Is the data cached and there's a "force refresh" command in WMI, or in this particular case, the "Availability" is just not reliable ?
I think there is caching going on somewhere. I've observed it recently.
I wrote code that was polling for updates to Win32_PnPSignedDriver via SelectQuery / ManagementObjectSearcher and the results appear to be cached because it never realizes that a new device/driver has been added. Running the query from a separate app instantly sees that it was updated.
You may have a look to your driver. According to the documentation, starting with Windows Vista, hardware that is not compatible with Windows Display Driver Model (WDDM) returns inaccurate property values for instances of this class. For me it's an another way to say that it's not reliable.

Why wont my windows service write to a file continuously?

I have created a windows service that checks installed printers and updates a file currently located at "C:\App\Data\info" (no file extension) Very simple, all it does is call EnumPrinters with the correct flags and dumps PRINTER_INFO_2 to a file.
Everything works exactly as expected in Visual Studio 2010, in the "testing" project leading me to believe the issue is not in my service. As soon as I install this as a windows service it stops looping. It will run through the loop once and never again.
Code Reference:
I am using the template from here: http://www.kencotutorials.com/WindowsService.aspx
and have only changed the service class file.
Initial thoughts are either security permissions or the wait function not returning.
Edit: I have already checked the whole file system to see if its being written elsewhere and confirmed that it is not.
This is the service loop function that is called by the template.
void CMyService::MyServiceLoop(void)
{
CheckPrinters(); // updates a PRINTER_INFO_2 struct with all installed printers
WritePrinterFile(); // writes the file (i know there's no issue with the actual writing)
Sleep(10000);
OutputDebugString("Done sleeping");
Return;
}
I have added OutputDebugString("Shell loop entered") at the start of the shell app loop.
I have also added OutputDebugString("Waiting for object") in front of the call to WaitForSingleObject()
The loop seems to hang on the WaitForSingleObject. Last message in DbgView is "Waiting for object".
Could be a lot of reasons. I'd recommend you add some OutputDebugString() calls (Win32 API function) and get DbgView.exe from Microsoft to see what is going on. Also, doesn't sound like you are doing this, but make sure you aren't writing to a mapped drive or network location, since your service most likely doesn't have access to those.
When you set up your Windows Service, did you specify an account on the Log On tab?
http://www.coretechnologies.com/WindowsServices/FAQ.html#AppNotWorkingFromService
The default Local System account almost surely doesn't have the rights to use the printers so be sure to set an account that can access the printers normally.