Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
d06ed39e
Unverified
Commit
d06ed39e
authored
May 20, 2019
by
Sebastian Roth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds ServiceStatus (phone) inquiry for iOS
parent
2f0369ea
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
1 deletions
+78
-1
example/lib/main.dart
+0
-1
ios/Classes/PermissionManager.h
+1
-0
ios/Classes/PermissionManager.m
+2
-0
ios/Classes/strategies/PhonePermissionStrategy.h
+17
-0
ios/Classes/strategies/PhonePermissionStrategy.m
+58
-0
No files found.
example/lib/main.dart
View file @
d06ed39e
...
...
@@ -28,7 +28,6 @@ class MyApp extends StatelessWidget {
.
where
((
PermissionGroup
permission
)
{
if
(
Platform
.
isIOS
)
{
return
permission
!=
PermissionGroup
.
unknown
&&
permission
!=
PermissionGroup
.
phone
&&
permission
!=
PermissionGroup
.
sms
&&
permission
!=
PermissionGroup
.
storage
;
}
else
{
...
...
ios/Classes/PermissionManager.h
View file @
d06ed39e
...
...
@@ -15,6 +15,7 @@
#import "LocationPermissionStrategy.h"
#import "MediaLibraryPermissionStrategy.h"
#import "PermissionStrategy.h"
#import "PhonePermissionStrategy.h"
#import "PhotoPermissionStrategy.h"
#import "SensorPermissionStrategy.h"
#import "SpeechPermissionStrategy.h"
...
...
ios/Classes/PermissionManager.m
View file @
d06ed39e
...
...
@@ -89,6 +89,8 @@
return
[
MediaLibraryPermissionStrategy
new
];
case
PermissionGroupMicrophone
:
return
[
AudioVideoPermissionStrategy
new
];
case
PermissionGroupPhone
:
return
[
PhonePermissionStrategy
new
];
case
PermissionGroupPhotos
:
return
[
PhotoPermissionStrategy
new
];
case
PermissionGroupReminders
:
...
...
ios/Classes/strategies/PhonePermissionStrategy.h
0 → 100644
View file @
d06ed39e
//
// PhonePermissionStrategy.h
// permission_handler
//
// Created by Sebastian Roth on 5/20/19.
//
#import <Foundation/Foundation.h>
#import "PermissionStrategy.h"
NS_ASSUME_NONNULL_BEGIN
@interface
PhonePermissionStrategy
:
NSObject
<
PermissionStrategy
>
@end
NS_ASSUME_NONNULL_END
ios/Classes/strategies/PhonePermissionStrategy.m
0 → 100644
View file @
d06ed39e
//
// PhonePermissionStrategy.m
// permission_handler
//
// Created by Sebastian Roth on 5/20/19.
//
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
#import "PhonePermissionStrategy.h"
@implementation
PhonePermissionStrategy
-
(
PermissionStatus
)
checkPermissionStatus
:(
PermissionGroup
)
permission
{
return
PermissionStatusUnknown
;
}
-
(
ServiceStatus
)
checkServiceStatus
:(
PermissionGroup
)
permission
{
// https://stackoverflow.com/a/5095058
if
(
!
[[
UIApplication
sharedApplication
]
canOpenURL
:[
NSURL
URLWithString
:
@"tel://"
]])
{
return
ServiceStatusNotApplicable
;
}
return
[
self
canDevicePlaceAPhoneCall
]
?
ServiceStatusEnabled
:
ServiceStatusDisabled
;
}
-
(
void
)
requestPermission
:(
PermissionGroup
)
permission
completionHandler
:(
PermissionStatusHandler
)
completionHandler
{
completionHandler
(
PermissionStatusUnknown
);
}
// https://stackoverflow.com/a/11595365
-
(
bool
)
canDevicePlaceAPhoneCall
{
/*
* Returns YES if the device can place a phone call
*/
// Check if the device can place a phone call
if
([[
UIApplication
sharedApplication
]
canOpenURL
:[
NSURL
URLWithString
:
@"tel://"
]])
{
// Device supports phone calls, lets confirm it can place one right now
CTTelephonyNetworkInfo
*
netInfo
=
[[
CTTelephonyNetworkInfo
alloc
]
init
];
CTCarrier
*
carrier
=
[
netInfo
subscriberCellularProvider
];
NSString
*
mnc
=
[
carrier
mobileNetworkCode
];
if
(([
mnc
length
]
==
0
)
||
([
mnc
isEqualToString
:
@"65535"
]))
{
// Device cannot place a call at this time. SIM might be removed.
return
NO
;
}
else
{
// Device can place a phone call
return
YES
;
}
}
else
{
// Device does not support phone calls
return
NO
;
}
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment