Delete Things
You can remove a thing by deleting it from the Kii Cloud. Once the thing is deleted, the following information will be deleted:
- All thing and owner information (note that the owners' Users and Groups are not deleted).
- All data stored in the thing scope (buckets, objects and topics).
The following sample code shows how to delete a thing.
Android
-
try { // Instantiate a thing by vendor thing ID. KiiThing thing = KiiThing.loadWithVendorThingID("rBnvSPOXBDF9r29GJeGS"); // Delete the thing. thing.delete(); } catch (AppException e) { // Handle the error. } catch (IOException e) { // Handle the error. }
-
// Instantiate a thing by vendor thing ID. KiiThing.loadWithVendorThingID("rBnvSPOXBDF9r29GJeGS", new KiiCallback<KiiThing>() { @Override public void onComplete(KiiThing result, Exception e) { if (e != null) { // Handle the error. return; } // Delete the thing. result.delete(new KiiCallback<KiiThing>() { @Override public void onComplete(KiiThing result, Exception e) { if (e != null) { // Handle the error. return; } } }); } });
iOS
Swift:
-
let thing : KiiThing do{ // Instantiate a thing by vendor thing ID. thing = try KiiThing.loadSynchronous(withVendorThingID: "rBnvSPOXBDF9r29GJeGS") }catch(let error as NSError){ // Handle the error. return } do{ // Delete the thing. try thing.deleteSynchronous() } catch let error as NSError { // Handle the error. return }
-
// Instantiate a thing by vendor thing ID. KiiThing.load(withVendorThingID: "rBnvSPOXBDF9r29GJeGS") { (thing , error) -> Void in if error != nil { // Handle the error. return } // Delete the thing. thing!.delete({ (deletedThing , error : Error?) -> Void in if error != nil { // Handle the error. return } }) }
Objective-C:
-
NSError* error = nil; // Instantiate a thing by vendor thing ID. KiiThing* thing = [KiiThing loadSynchronousWithVendorThingID:@"rBnvSPOXBDF9r29GJeGS" error:&error]; // Delete the thing. [thing deleteSynchronous:&error]; if (error != nil) { // Handle the error. return; }
-
// Instantiate a thing by vendor thing ID. [KiiThing loadWithVendorThingID:@"rBnvSPOXBDF9r29GJeGS" block:^(KiiThing *thing, NSError *error) { if (error != nil) { // Handle the error. return; } // Delete the thing. [thing delete:^(KiiThing *thing, NSError *error) { if (error != nil) { // Handle the error. return; } }]; }];
JavaScript
// Instantiate a thing by vendor thing ID.
KiiThing.loadWithVendorThingID("rBnvSPOXBDF9r29GJeGS",{
success: function(thing) {
// Delete the thing.
thing.deleteThing({
success: function(theThing) {
// Do something.
},
failure: function(theThing, error) {
// Handle the error.
}
});
},
failure: function(error) {
// Handle the error.
}
});