Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Housekeeping #73

Merged
merged 7 commits into from
Aug 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions ISHPermissionKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
1B06A05A1D70949A00C7F8ED /* ISHPermissionKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6A46B119D712AC00B11E88 /* ISHPermissionKit.framework */; };
1B06A05B1D70949A00C7F8ED /* ISHPermissionKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DC6A46B119D712AC00B11E88 /* ISHPermissionKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1B09324A1D7069C70095A74A /* ISHPermissionRequestContacts.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B0932481D7069C70095A74A /* ISHPermissionRequestContacts.m */; };
1B09324C1D7069D90095A74A /* ISHPermissionRequestContacts.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B09324B1D7069D90095A74A /* ISHPermissionRequestContacts.h */; };
1B09324D1D7069D90095A74A /* ISHPermissionRequestContacts.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B09324B1D7069D90095A74A /* ISHPermissionRequestContacts.h */; };
Expand Down Expand Up @@ -45,7 +47,6 @@
1B96D6011D6F12CF0026A4FC /* ISHPermissionRequestSpeechRecognition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B96D5FF1D6F12CF0026A4FC /* ISHPermissionRequestSpeechRecognition.h */; };
1B96D6021D6F12CF0026A4FC /* ISHPermissionRequestSpeechRecognition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B96D5FF1D6F12CF0026A4FC /* ISHPermissionRequestSpeechRecognition.h */; };
1B96D6031D6F12CF0026A4FC /* ISHPermissionRequestSpeechRecognition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B96D5FF1D6F12CF0026A4FC /* ISHPermissionRequestSpeechRecognition.h */; };
1BAB47C21D6F31F300872D79 /* Speech.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BAB47C11D6F31F300872D79 /* Speech.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
1BAB47F01D6F36FD00872D79 /* Speech.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BAB47C11D6F31F300872D79 /* Speech.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
1BAB47F11D6F370600872D79 /* Speech.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BAB47C11D6F31F300872D79 /* Speech.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
1BC93E4E1D7063D20033B6E8 /* ISHPermissionRequestMusicLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BC93E491D7063D20033B6E8 /* ISHPermissionRequestMusicLibrary.m */; };
Expand Down Expand Up @@ -142,7 +143,6 @@
DC6A46AA19D712AC00B11E88 /* ISHPermissionRequestViewControllerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = DC799EB5195C113900A0CA36 /* ISHPermissionRequestViewControllerDelegate.h */; };
DC6A46AB19D712AC00B11E88 /* ISHPermissionRequestPhotoCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = DC5E5BB6195D78800092EAFD /* ISHPermissionRequestPhotoCamera.h */; };
DC6A46AC19D712AC00B11E88 /* ISHPermissionRequestHealth.h in Headers */ = {isa = PBXBuildFile; fileRef = DCD56C7B1962BB8600508F4A /* ISHPermissionRequestHealth.h */; settings = {ATTRIBUTES = (Public, ); }; };
DC6A46B519D94E6A00B11E88 /* libISHPermissionKitLib+HealthKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6A468719D7125300B11E88 /* libISHPermissionKitLib+HealthKit.a */; };
DC6A8A7D19633180005AC5BD /* ISHPermissionCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = DC1A80A8195B22A10069235F /* ISHPermissionCategory.h */; settings = {ATTRIBUTES = (Public, ); }; };
DC6A8A7E19633180005AC5BD /* ISHPermissionKit.h in Headers */ = {isa = PBXBuildFile; fileRef = DCC1BFAA195B174200362559 /* ISHPermissionKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
DC6A8A7F19633180005AC5BD /* ISHPermissionRequestViewController+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DC799EB3195C0CF300A0CA36 /* ISHPermissionRequestViewController+Private.h */; };
Expand Down Expand Up @@ -210,6 +210,13 @@
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
1B06A05C1D70949A00C7F8ED /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DCC1BF9C195B174200362559 /* Project object */;
proxyType = 1;
remoteGlobalIDString = DC6A468819D712AC00B11E88;
remoteInfo = "ISHPermissionKit+HealthKit";
};
DC6A46B319D94E2700B11E88 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DCC1BF9C195B174200362559 /* Project object */;
Expand All @@ -234,6 +241,17 @@
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
1B06A05E1D70949A00C7F8ED /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
1B06A05B1D70949A00C7F8ED /* ISHPermissionKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
DC6A468319D7125300B11E88 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -382,8 +400,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1BAB47C21D6F31F300872D79 /* Speech.framework in Frameworks */,
DC6A46B519D94E6A00B11E88 /* libISHPermissionKitLib+HealthKit.a in Frameworks */,
1B06A05A1D70949A00C7F8ED /* ISHPermissionKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -426,6 +443,8 @@
DCD56C771962AEDC00508F4A /* ISHPermissionRequestAccount.m */,
DC6A8ACB19641549005AC5BD /* ISHPermissionRequestAddressBook.h */,
DC6A8ACC19641549005AC5BD /* ISHPermissionRequestAddressBook.m */,
1B09324B1D7069D90095A74A /* ISHPermissionRequestContacts.h */,
1B0932481D7069C70095A74A /* ISHPermissionRequestContacts.m */,
DC6A8AD119642793005AC5BD /* ISHPermissionRequestEventStore.h */,
DC6A8AD219642793005AC5BD /* ISHPermissionRequestEventStore.m */,
DCD56C7B1962BB8600508F4A /* ISHPermissionRequestHealth.h */,
Expand All @@ -434,8 +453,12 @@
DC799EBE195C186100A0CA36 /* ISHPermissionRequestLocation.m */,
DC5E5BAC195D67500092EAFD /* ISHPermissionRequestMicrophone.h */,
DC5E5BAD195D67500092EAFD /* ISHPermissionRequestMicrophone.m */,
1B63F89C1D6DF60500B14122 /* ISHPermissionRequestModernPhotoLibrary.h */,
1B63F8931D6DF5F200B14122 /* ISHPermissionRequestModernPhotoLibrary.m */,
DCAEF7BF195C5B6B0074EB5B /* ISHPermissionRequestMotion.h */,
DCAEF7C0195C5B6B0074EB5B /* ISHPermissionRequestMotion.m */,
1BC93E521D7063F10033B6E8 /* ISHPermissionRequestMusicLibrary.h */,
1BC93E491D7063D20033B6E8 /* ISHPermissionRequestMusicLibrary.m */,
DC5E5BC1195DAD750092EAFD /* ISHPermissionRequestNotificationsLocal.h */,
DC5E5BC2195DAD750092EAFD /* ISHPermissionRequestNotificationsLocal.m */,
DC96E8CC1B95CAAD0019E958 /* ISHPermissionRequestNotificationsRemote.h */,
Expand All @@ -446,16 +469,10 @@
DC5E5BB2195D6E890092EAFD /* ISHPermissionRequestPhotoLibrary.m */,
1B4513041D6DC02D00D6E47C /* ISHPermissionRequestSiri.h */,
1B4512FB1D6DC01200D6E47C /* ISHPermissionRequestSiri.m */,
1B63F89C1D6DF60500B14122 /* ISHPermissionRequestModernPhotoLibrary.h */,
1B63F8931D6DF5F200B14122 /* ISHPermissionRequestModernPhotoLibrary.m */,
1B96D5FF1D6F12CF0026A4FC /* ISHPermissionRequestSpeechRecognition.h */,
1B96D5F61D6F12C00026A4FC /* ISHPermissionRequestSpeechRecognition.m */,
1B6988491D6F40F400C8EAB8 /* ISHPermissionRequestUserNotification.h */,
1B69884A1D6F40F400C8EAB8 /* ISHPermissionRequestUserNotification.m */,
1BC93E521D7063F10033B6E8 /* ISHPermissionRequestMusicLibrary.h */,
1BC93E491D7063D20033B6E8 /* ISHPermissionRequestMusicLibrary.m */,
1B09324B1D7069D90095A74A /* ISHPermissionRequestContacts.h */,
1B0932481D7069C70095A74A /* ISHPermissionRequestContacts.m */,
);
path = Requests;
sourceTree = "<group>";
Expand Down Expand Up @@ -495,9 +512,9 @@
children = (
DC1A80A8195B22A10069235F /* ISHPermissionCategory.h */,
DCC1BFAA195B174200362559 /* ISHPermissionKit.h */,
DC799EB3195C0CF300A0CA36 /* ISHPermissionRequestViewController+Private.h */,
DC1A80AE195B2C960069235F /* ISHPermissionRequestViewController.h */,
DC1A80AF195B2C960069235F /* ISHPermissionRequestViewController.m */,
DC799EB3195C0CF300A0CA36 /* ISHPermissionRequestViewController+Private.h */,
DC799EB5195C113900A0CA36 /* ISHPermissionRequestViewControllerDelegate.h */,
DC1A80A1195B21DC0069235F /* ISHPermissionsViewController.h */,
DC1A80A2195B21DC0069235F /* ISHPermissionsViewController.m */,
Expand Down Expand Up @@ -808,11 +825,13 @@
DCC1BFC1195B176E00362559 /* Sources */,
DCC1BFC2195B176E00362559 /* Frameworks */,
DCC1BFC3195B176E00362559 /* Resources */,
1B06A05E1D70949A00C7F8ED /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
DC6A46B419D94E2700B11E88 /* PBXTargetDependency */,
1B06A05D1D70949A00C7F8ED /* PBXTargetDependency */,
);
name = PermissionsTestApp;
productName = PermissionsTestApp;
Expand Down Expand Up @@ -860,12 +879,12 @@
projectRoot = "";
targets = (
DCC1BFA4195B174200362559 /* ISHPermissionKit */,
DCC1BFAF195B174200362559 /* ISHPermissionKitTests */,
DCC1BFC4195B176E00362559 /* PermissionsTestApp */,
DC6A468819D712AC00B11E88 /* ISHPermissionKit+HealthKit */,
DCAEF7C9195C60070074EB5B /* ISHPermissionKitLib */,
DC7790B219617CD7007CB2BC /* ISHPermissionKitLibTests */,
DC6A465E19D7125300B11E88 /* ISHPermissionKitLib+HealthKit */,
DC6A468819D712AC00B11E88 /* ISHPermissionKit+HealthKit */,
DCC1BFC4195B176E00362559 /* PermissionsTestApp */,
DCC1BFAF195B174200362559 /* ISHPermissionKitTests */,
DC7790B219617CD7007CB2BC /* ISHPermissionKitLibTests */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -1054,6 +1073,11 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
1B06A05D1D70949A00C7F8ED /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DC6A468819D712AC00B11E88 /* ISHPermissionKit+HealthKit */;
targetProxy = 1B06A05C1D70949A00C7F8ED /* PBXContainerItemProxy */;
};
DC6A46B419D94E2700B11E88 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DC6A465E19D7125300B11E88 /* ISHPermissionKitLib+HealthKit */;
Expand Down Expand Up @@ -1381,6 +1405,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
INFOPLIST_FILE = PermissionsTestApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = YES;
OTHER_LDFLAGS = "-ObjC";
Expand All @@ -1395,6 +1420,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
INFOPLIST_FILE = PermissionsTestApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = NO;
OTHER_LDFLAGS = "-ObjC";
Expand Down
22 changes: 19 additions & 3 deletions ISHPermissionKit/Requests/ISHPermissionRequestAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ @interface ISHPermissionRequestAccount ()
@implementation ISHPermissionRequestAccount

- (BOOL)allowsConfiguration {
// Facebook requires further configuration
return (self.permissionCategory == ISHPermissionCategorySocialFacebook);
switch (self.permissionCategory) {
case ISHPermissionCategorySocialFacebook:
case ISHPermissionCategorySocialTencentWeibo:
return YES;

case ISHPermissionCategorySocialSinaWeibo:
case ISHPermissionCategorySocialTwitter:
return NO;

default:
break;
}

NSAssert(NO, @"Invalid category: %@", @(self.permissionCategory));
return NO;
}

- (NSString *)accountTypeIdentifier {
Expand All @@ -38,8 +51,11 @@ - (NSString *)accountTypeIdentifier {
return ACAccountTypeIdentifierTencentWeibo;

default:
return nil;
break;
}

NSAssert(NO, @"Invalid category: %@", @(self.permissionCategory));
return nil;
}

- (ACAccountType *)accountType {
Expand Down
93 changes: 69 additions & 24 deletions PermissionsTestApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#import "AppDelegate.h"
#import "SamplePermissionViewController.h"
#import "GrantedPermissionsViewController.h"

@import Accounts;
@import HealthKit;

@interface AppDelegate ()
@property (nonatomic, weak) GrantedPermissionsViewController *rootViewController;
Expand All @@ -32,25 +34,45 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

+ (NSArray<NSNumber *> *)requiredPermissions {
// The demo app requests all supported permissions. Those that
// require special capabilities have been commented out since
// they require additional configuration in Xcode.
return @[
@(ISHPermissionCategoryEvents),
@(ISHPermissionCategoryReminders),
@(ISHPermissionCategoryAddressBook),
@(ISHPermissionCategoryContacts),
@(ISHPermissionCategoryActivity),

// requires Health capability & entitlements
// @(ISHPermissionCategoryHealth),

// If you want to request both, the order is important,
// as Always implies WhenInUse, too
@(ISHPermissionCategoryLocationWhenInUse),
@(ISHPermissionCategoryLocationAlways),
@(ISHPermissionCategoryActivity),

@(ISHPermissionCategoryMicrophone),
@(ISHPermissionCategoryPhotoLibrary),
@(ISHPermissionCategoryModernPhotoLibrary),
@(ISHPermissionCategoryPhotoCamera),
@(ISHPermissionCategoryNotificationLocal),
@(ISHPermissionCategorySocialTwitter),
// requires Push capability & entitlements to actually work
@(ISHPermissionCategoryNotificationRemote),

@(ISHPermissionCategorySocialFacebook),
@(ISHPermissionCategorySocialTwitter),
@(ISHPermissionCategorySocialSinaWeibo),
// TODO: alert cannot be presented
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is #72

@(ISHPermissionCategorySocialTencentWeibo),

@(ISHPermissionCategoryAddressBook),
@(ISHPermissionCategoryContacts),
@(ISHPermissionCategoryEvents),
@(ISHPermissionCategoryReminders),
@(ISHPermissionCategoryMusicLibrary),

#ifdef NSFoundationVersionNumber_iOS_9_0
@(ISHPermissionCategoryUserNotification),
// reqquires Siri capability & entitlements
// @(ISHPermissionCategorySiri),
@(ISHPermissionCategorySpeechRecognition),
@(ISHPermissionCategoryUserNotification),
#endif
];
}
Expand Down Expand Up @@ -86,23 +108,46 @@ - (ISHPermissionRequestViewController *)permissionsViewController:(ISHPermission
}

- (void)permissionsViewController:(ISHPermissionsViewController *)vc didConfigureRequest:(ISHPermissionRequest *)request {
if (request.permissionCategory == ISHPermissionCategoryNotificationLocal) {
// the demo app only requests permissions for badges
UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
ISHPermissionRequestNotificationsLocal *localNotesRequest = (ISHPermissionRequestNotificationsLocal *)([request isKindOfClass:[ISHPermissionRequestNotificationsLocal class]] ? request : nil);
[localNotesRequest setNotificationSettings:setting];
}

if (request.permissionCategory == ISHPermissionCategorySocialFacebook) {
ISHPermissionRequestAccount *accountRequest = (ISHPermissionRequestAccount *)([request isKindOfClass:[ISHPermissionRequestAccount class]] ? request : nil);

NSDictionary *options = @{
ACFacebookAppIdKey: @"YOUR-API-KEY",
ACFacebookPermissionsKey: @[@"email", @"user_about_me"],
ACFacebookAudienceKey: ACFacebookAudienceFriends
};

[accountRequest setOptions:options];
switch (request.permissionCategory) {
case ISHPermissionCategoryHealth: {
ISHPermissionRequestHealth *healthRequest = (ISHPermissionRequestHealth *)([request isKindOfClass:[ISHPermissionRequestHealth class]] ? request : nil);
HKQuantityType *heartRate = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate];
healthRequest.objectTypesRead = [NSSet setWithObjects:heartRate, nil];
healthRequest.objectTypesWrite = [NSSet setWithObjects:heartRate, nil];
break;
}

case ISHPermissionCategoryNotificationLocal: {
// the demo app only requests permissions for badges
UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
ISHPermissionRequestNotificationsLocal *localNotesRequest = (ISHPermissionRequestNotificationsLocal *)([request isKindOfClass:[ISHPermissionRequestNotificationsLocal class]] ? request : nil);
[localNotesRequest setNotificationSettings:setting];
break;
}

case ISHPermissionCategorySocialFacebook:
case ISHPermissionCategorySocialTencentWeibo: {
ISHPermissionRequestAccount *accountRequest = (ISHPermissionRequestAccount *)([request isKindOfClass:[ISHPermissionRequestAccount class]] ? request : nil);

NSDictionary *options;
if ([accountRequest.accountTypeIdentifier isEqualToString:ACAccountTypeIdentifierFacebook]) {
options = @{
ACFacebookAppIdKey: @"YOUR-API-KEY",
ACFacebookPermissionsKey: @[@"email", @"user_about_me"],
ACFacebookAudienceKey: ACFacebookAudienceFriends,
};
} else if ([accountRequest.accountTypeIdentifier isEqualToString:ACAccountTypeIdentifierTencentWeibo]) {
options = @{
ACTencentWeiboAppIdKey: @"YOUR-API-KEY",
};
}

[accountRequest setOptions:options];
break;
}

default:
break;
}
}

Expand Down
4 changes: 4 additions & 0 deletions PermissionsTestApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<string>Explain why you use the camera</string>
<key>NSContactsUsageDescription</key>
<string>Explain why you use contacts</string>
<key>NSHealthShareUsageDescription</key>
<string>Explain why you read heart rates</string>
<key>NSHealthUpdateUsageDescription</key>
<string>Explain why you write heart rates</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Explain why you use the location (always)</string>
<key>NSLocationWhenInUseUsageDescription</key>
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ where the system APIs only provide implicit methods of doing so.
* Siri
* Speech Recognition

The library and sample app compile with the **iOS 9.3 SDK** and later, and require a
**deployment target of iOS 7** or later. Permission categories that were added after
iOS 7 will be skipped on unsupported versions.
The library and sample app compile with the **iOS 9.3 SDK** and later. The library
deploys back to **iOS 7**, while the sample app makes use of dynamic frameworks and
therefore has a deployment target of iOS 8. Permission categories that were added
later than the deployment target will be skipped on unsupported versions.

ISHPermissionKit verifies that the required usage descriptions are provided in your
apps `Info.plist`. If the `DEBUG` preprocessor macro is set, it will assert and
Expand Down