-
Notifications
You must be signed in to change notification settings - Fork 44
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
Housekeeping #73
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bdd1019
Use the dynamic framework variant in the sample app
628f5e5
Add Health sample code
b0ad62f
Add required TencentWeibo configuration
6811a99
Sort permission kit classes by name in Xcode
21f231d
Reorder targets
eaf16c1
Remove Speech framework from test app
de3c608
Fix warning re: unhandled case
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ | |
#import "AppDelegate.h" | ||
#import "SamplePermissionViewController.h" | ||
#import "GrantedPermissionsViewController.h" | ||
|
||
@import Accounts; | ||
@import HealthKit; | ||
|
||
@interface AppDelegate () | ||
@property (nonatomic, weak) GrantedPermissionsViewController *rootViewController; | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
]; | ||
} | ||
|
@@ -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; | ||
} | ||
} | ||
|
||
|
This file contains 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
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this follow the same pattern as above without a default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code above probably raises a warning... we don't really want to list all ~15 categories, so I believe
default
is ok here. Plus, we usually don't care here if new categories are added.