We can not use the Rainbow SDK without first creating an instance of the Rainbow class. That class is so important that it exists as a singleton:

Rainbow *rainbow = [Rainbow instance];

Once we have that instance, we then need to pass the appSecret and a filePath:

[rainbow setAppSecret:{secret} andFilePath:{path}];

We get the {secret} from this site, when we registered the app. The {path} is used to store the connected Cloud Service accounts. It may be an empty string, but in this case your users will have to connect to their accounts every time they start your app.

The last step is to provide the keys for each Cloud Service. These are the clientID, clientSecret and callbacks that you put on a Cloud Service’s site. Each Cloud Service uses a different name for these keys, and thus we created the service.plist file in the demo code. You can remove the Cloud Services that you are not interested in or you can complete only those that you are. Once you have that file, create an NSDictionary from it and then call the method:

NSDictionary *services = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Service" ofType:@"plist"]];
[rainbow addServiceKeys:services];

Now we are ready to start using the Rainbow SDK. Based on the non-empty values in the service.plist file, the method getServices will return the Cloud Services that you can use:

(NSDictionary*)services = [rainbow getServices];

The key of that NSDictionary is the name of the Cloud Service, and the value is an instance of the RService class. The name for each Cloud Service is the following:

  • Box
  • DropBox
  • GoogleDrive
  • IDrive
  • MediaFire
  • OneDrive
  • ShareFile
  • SkyDrive
  • SugarSync

If you use a different name you will get a nill object. Once you have the instance of the RService class, you can either list the connected accounts (RServiceItem instance) or you can connect to a new account. From the RServiceItem instance you can get the RManager instance and then perform any of the supported action on that Cloud Service.