IBeacon region monitoring not work consistently across devices

前端 未结 2 1700
旧巷少年郎
旧巷少年郎 2021-02-10 05:30

When testing with a simple app to test beacon region monitoring I seem to get very inconsistent results depending on the device (not the device model, the specific device). The

相关标签:
2条回答
  • 2021-02-10 05:38

    Monitoring may not work for several reasons. One being that App Background Refresh is disabled to save your battery. Another one is neglecting to ensure you have setup the correct App Capabilities.

    Background Modes

    If this doesn't work there is a great post you can read that details all of the items to troubleshoot.

    iBeacon StartMonitoringForRegion Doesn’t Work

    0 讨论(0)
  • 2021-02-10 05:49

    I Found the problem. Apparently to use iBeacons in the way that is described in the documents users are required to have the Background Refresh setting enabled in the Settings. To check for this setting I use the following snippet:

    if ([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusAvailable) {
    
        NSLog(@"Background updates are available for the app.");
    }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied)
    {
        NSLog(@"The user explicitly disabled background behavior for this app or for the whole system.");
    }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusRestricted)
    {
        NSLog(@"Background updates are unavailable and the user cannot enable them again. For example, this status can occur when parental controls are in effect for the current user.");
    }
    

    Found in this answer: Detecting user settings for Background App Refresh in iOS 7

    0 讨论(0)
提交回复
热议问题