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
3c78c95c
Commit
3c78c95c
authored
Jun 15, 2021
by
Maurits van Beusekom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix deprecation issue
parent
72d3dde2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
22 deletions
+37
-22
permission_handler/ios/Classes/strategies/PhonePermissionStrategy.m
+37
-22
No files found.
permission_handler/ios/Classes/strategies/PhonePermissionStrategy.m
View file @
3c78c95c
...
...
@@ -13,40 +13,55 @@
@implementation
PhonePermissionStrategy
-
(
PermissionStatus
)
checkPermissionStatus
:(
PermissionGroup
)
permission
{
return
PermissionStatusDenied
;
return
PermissionStatusDenied
;
}
-
(
ServiceStatus
)
checkServiceStatus
:(
PermissionGroup
)
permission
{
// https://stackoverflow.com/a/5095058
if
(
!
[[
UIApplication
sharedApplication
]
canOpenURL
:[
NSURL
URLWithString
:
@"tel://"
]])
{
return
ServiceStatusNotApplicable
;
}
return
[
self
canDevicePlaceAPhoneCall
]
?
ServiceStatusEnabled
:
ServiceStatusDisabled
;
// 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
(
PermissionStatusPermanentlyDenied
);
completionHandler
(
PermissionStatusPermanentlyDenied
);
}
// https://stackoverflow.com/a/11595365
/**
* Returns YES if the device can place a phone call.
*/
-
(
bool
)
canDevicePlaceAPhoneCall
{
/*
* Returns YES if the device can place a phone call
*/
// 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
CTTelephonyNetworkInfo
*
netInfo
=
[[
CTTelephonyNetworkInfo
alloc
]
init
];
if
(
@available
(
iOS
12
.
0
,
*
))
{
NSDictionary
<
NSString
*
,
CTCarrier
*>
*
providers
=
[
netInfo
serviceSubscriberCellularProviders
];
for
(
NSString
*
key
in
providers
)
{
CTCarrier
*
carrier
=
[
providers
objectForKey
:
key
];
if
([
self
canPlacePhoneCallWithCarrier
:
carrier
])
{
return
YES
;
}
}
return
NO
;
}
else
{
CTCarrier
*
carrier
=
[
netInfo
subscriberCellularProvider
];
return
[
self
canPlacePhoneCallWithCarrier
:
carrier
];
}
}
-
(
bool
)
canPlacePhoneCallWithCarrier
:
(
CTCarrier
*
)
carrier
{
// https://stackoverflow.com/a/11595365
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
;
}
}
@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