Last active
November 25, 2016 23:23
-
-
Save scottmkroberts/aeab294fc5457532f5dc462a6994dfe4 to your computer and use it in GitHub Desktop.
Facebook auto check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*The following mimics thefunctionality of showDialog in how to call the function but instead of using the method | |
* to know what dialog to show we use the passed method name to check for that permssion e.g. "email". | |
*/ | |
// In www/facebook-native.js | |
exports.checkHasCorrectPermissions = function checkHasCorrectPermissions (s, f) { | |
exec(s, f, 'FacebookConnectPlugin', 'checkHasCorrectPermissions', []) | |
} | |
// In src/ios/FacebookConnectPlugin.h | |
- (void) checkHasCorrectPermissions:(CDVInvokedUrlCommand*)command | |
// In src/ios/FacebookConnectPlugin.m | |
- (void) checkHasCorrectPermissions:(CDVInvokedUrlCommand*)command{ | |
NSArray *permissions = ["email","user_friends","user_likes","user_birthday","user_photos"]; | |
NSSet *grantedPermissions = [FBSDKAccessToken currentAccessToken].permissions; //gets current list of permissions | |
for (NSString value in permissions) { | |
if !([grantedPermissions containsObject:value]) { //checks if permissions does not exists | |
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; | |
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; | |
return; | |
} | |
} | |
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; | |
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment