forked from organicmaps/organicmaps
[MAPSME-3810] [ios] Added CanUseNetwork check to NetworkPolicy.
This commit is contained in:
parent
d43d6ac2d6
commit
708527f268
2 changed files with 14 additions and 0 deletions
|
@ -8,4 +8,6 @@ void CallPartnersApi(platform::PartnersApiFn fn, bool force = false);
|
|||
|
||||
void SetStage(platform::NetworkPolicy::Stage state);
|
||||
platform::NetworkPolicy::Stage GetStage();
|
||||
|
||||
bool CanUseNetwork();
|
||||
} // namespace network_policy
|
||||
|
|
|
@ -78,4 +78,16 @@ np::Stage GetStage()
|
|||
return np::Stage::Never;
|
||||
return np::Stage::Session;
|
||||
}
|
||||
|
||||
bool CanUseNetwork()
|
||||
{
|
||||
auto const connectionType = GetPlatform().ConnectionStatus();
|
||||
if (connectionType == Platform::EConnectionType::CONNECTION_NONE)
|
||||
return false;
|
||||
if (connectionType == Platform::EConnectionType::CONNECTION_WIFI)
|
||||
return true;
|
||||
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
|
||||
NSDate * policyDate = [ud objectForKey:kNetworkingPolicyTimeStamp];
|
||||
return [policyDate compare:[NSDate date]] == NSOrderedDescending;
|
||||
}
|
||||
} // namespace network_policy
|
||||
|
|
Loading…
Add table
Reference in a new issue