Skip to content
fkmhrk edited this page Oct 12, 2013 · 4 revisions

UserAPI

Get UserAPI instance

require_once ('<library_root>'. '/src/kii/KiiAppAPI.php');

$context = new KiiContext(APP_ID, APP_KEY, SITE);
$appApi = new KiiAppAPI($context);
$api = $appApi->userAPI();

Install registrationID(Android) / deviceToken(iOS)

try {
	$installationId = $api->installDevice($user, UserAPI::OS_ANDROID, $regId);
} catch (CloudException $e) {
	//error handling
}

If deviceType(2nd argument) is UserAPI::OS_IOS, you can set 4th argument to tell that this deviceToken is for development / production.

try {
	// TRUE : development / FALSE : production(default)
	$installationId = $api->installDevice($user, UserAPI::OS_IOS, $deviceToken, TRUE);
} catch (CloudException $e) {
	//error handling
}

Uninstall registrationID(Android) / deviceToken(iOS)

try {
	$api->uninstallDevice(UserAPI::OS_ANDROID, $regId);
} catch (CloudException $e) {
	//error handling
}

Subscribe Topic / Bucket

$user = $appApi->login('fkm', 'password123456');
$topic = new KiiTopic($user, 'test');

try {
	$api->subscribe($user, $topic);
} catch (CloudException $e) {
	//error handling
}