Checking the Social Network Integration Status
Getting a list of integrated services
The following sample shows how you can get a list of social network services currently being linked to the user.
-
Uri uri = Uri.parse("Set the URI of an existing user here"); try { // Instantiate a user. KiiUser user = KiiUser.createByUri(uri); // Refresh the user. user.refresh(); // Get social network accounts linked to the user. Map<Provider, SocialAccountInfo> linkedAccounts = user.getLinkedSocialAccounts(); // Get information of the Facebook account linked to the user. SocialAccountInfo facebookInfo = linkedAccounts.get(Provider.FACEBOOK); } catch (IOException e) { // Handle the error. } catch (AppException e) { // Handle the error. }
-
Uri uri = Uri.parse("Set the URI of an existing user here"); // Instantiate a user. KiiUser user = KiiUser.createByUri(uri); // Refresh the user. user.refresh(new KiiUserCallBack() { @Override public void onRefreshCompleted(int token, Exception exception) { if (exception != null) { // Handle the error. return; } // Get social network accounts linked to the user. Map<Provider, SocialAccountInfo> linkedAccounts = user.getLinkedSocialAccounts(); // Get information of the Facebook account linked to the user. SocialAccountInfo facebookInfo = linkedAccounts.get(Provider.FACEBOOK); } });
Checking if a service is already integrated
The following sample code shows how you can check if the specified social network service is already linked to the user.
-
Uri uri = Uri.parse("Set the URI of an existing user here"); try { // Instantiate a user. KiiUser user = KiiUser.createByUri(uri); // Refresh the user. user.refresh(); if (user.isLinkedWithSocialProvider(Provider.FACEBOOK)) { // A Facebook account is linked to this user. } if (user.isLinkedWithSocialProvider(Provider.TWITTER)) { // A Twitter account is linked to this user. } } catch (IOException e) { // Handle the error. } catch (AppException e) { // Handle the error. }
-
Uri uri = Uri.parse("Set the URI of an existing user here"); // Instantiate a user. KiiUser user = KiiUser.createByUri(uri); // Refresh the user. user.refresh(new KiiUserCallBack() { @Override public void onRefreshCompleted(int token, Exception exception) { if (exception != null) { // Handle the error. return; } if (user.isLinkedWithSocialProvider(Provider.FACEBOOK)) { // A Facebook account is linked to this user. } if (user.isLinkedWithSocialProvider(Provider.TWITTER)) { // A Twitter account is linked to this user. } } });