iOS Question Apps that declare support for location in the UIBackgroundModes key

b4xscripter

Member
Licensed User
Longtime User
Hi,
First of all, many thanks for your support!
My app is rejected by App Store for this reason (they say):

**********************
We noticed that your app declares support for location in the UIBackgroundModes key in your Info.plist file but does not have any features that require persistent location. Apps that declare support for location in the UIBackgroundModes key in your Info.plist file must have features that require persistent location.

Next Steps

To resolve this issue, please revise your app to include features that require the persistent use of real-time location updates while the app is in the background.

If your app does not require persistent real-time location updates, please remove the "location" setting from the UIBackgroundModes key. You may wish to use the significant-change location service or the region monitoring location service if persistent real-time location updates are not required for your app features.


**********************


It is true, for my app I need to have a background running that works perfectly updating location. So my code (fragments) is:


B4X:
    #PlistExtra:<key>NSLocationAlwaysUsageDescription</key><string>Track your location in the background for better ad revenue.</string>
    #PlistExtra:<key>NSLocationUsageDescription</key><string>Used to display the current navigation data.</string>
    #PlistExtra: <key>UIBackgroundModes</key><array><string>location</string></array>
    #MinVersion: 8
    #Entitlement: <key>aps-environment</key><string>production</string>


B4X:
#If OBJC

- (BOOL)isSignificantLocationAvailable {
    if([CLLocationManager significantLocationChangeMonitoringAvailable]) {
      return YES;
    }
    return NO;
}

#end if

Sub StartBackground(lm As LocationManager, MinimumDistance As Double)
    Dim no As NativeObject = lm
    no = no.GetField("manager")
    If App.OSVersion >= 8 Then
        no.RunMethod("requestAlwaysAuthorization", Null)
    End If
    If App.OSVersion >= 9 Then
        no.RunMethod("setAllowsBackgroundLocationUpdates:", Array(True))
    End If
    no.SetField("distanceFilter", MinimumDistance)
    no.RunMethod("startUpdatingLocation", Null)
End Sub

Private Sub Application_Start (Nav As NavigationController)

   
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Page1")
    NavControl.ShowPage(Page1)
   
    App.RegisterUserNotifications(True, True, True) 'request permission for notifications
    App.ApplicationIconBadgeNumber = 0
   
    If App.LaunchOptions.IsInitialized Then
        Dim ln As Notification =       App.LaunchOptions.Get("UIApplicationLaunchOptionsLocalNotificationKey")
        If ln.IsInitialized Then
            hd.ToastMessageShow("Application was started from a notification: " & ln.AlertBody, True)
        End If
    End If
   
    fm.Initialize("fm")
    WKWebView3.Loadurl("http://85.88.153.23.nip.io:7095/promotions")
    Dim no As NativeObject = WKWebView3
    no.GetField("scrollView").SetField("bounces", False)
   
   
   
    LocManager.Initialize("LocManager")
   
    'in background....
    Dim no As NativeObject = LocManager
    no = no.GetField("manager")
    no.SetField("pausesLocationUpdatesAutomatically", False)
    StartBackground(LocManager, 0) 'replaces locManager.Start
    'in background....
   
    LocManager_AuthorizationStatusChanged(0)
    tn.Initialize("tn")


End Sub


Sub AllowPauseLocationAutomatically(lm As LocationManager, ActivityType As Int) 'ignore
    Dim no As NativeObject = lm
    no = no.GetField("manager")
    no.SetField("activityType", ActivityType)
    no.SetField("pausesLocationUpdatesAutomatically", True)
End Sub


Private Sub LocManager_AuthorizationStatusChanged (Status As Int)
    If Not(LocManager.IsAuthorized Or LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_NOT_DETERMINED) Then
        Log("Not authorized")
    End If
    StartLocationUpdates
End Sub

Private Sub StartLocationUpdates
    'if the user allowed us to use the location service or if we never asked the user before then we call LocationManager.Start.
    If LocManager.IsAuthorized Or LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_NOT_DETERMINED Then
        LocManager.Start(0)
    End If
    LocManager.StartHeading
End Sub

Sub SearchForBeacon(UUID As String, Identifier As String) As Object
    If LocManager.IsAuthorized Or LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_NOT_DETERMINED Then
        Dim no As NativeObject = LocManager
        no = no.GetField("manager")
        If LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_NOT_DETERMINED Then
            no.RunMethod("requestWhenInUseAuthorization", Null)
        End If
        Dim nsuuid, br As NativeObject
        nsuuid = nsuuid.Initialize("NSUUID").RunMethod("alloc", Null).RunMethod("initWithUUIDString:", Array(UUID))
        br = br.Initialize("CLBeaconRegion").RunMethod("alloc", Null).RunMethod("initWithProximityUUID:identifier:", _
        Array(nsuuid, Identifier))
       
        no.RunMethod("startRangingBeaconsInRegion:", Array(br))
        Return br
    Else
        Log("Not authorized!")
        Return Null
    End If
End Sub

Private Sub Application_Foreground
    StartLocationUpdates
End Sub

Private Sub Application_Background
    fm.FCMDisconnect 'should be called from Application_Background
    'LocManager.Stop
    'LocManager.StopHeading
End Sub

Private Sub LocManager_HeadingChanged (MagneticHeading As Double, TrueHeading As Double)
    If TrueHeading >= 0 Then
    '    lblHeading.Text = NumberFormat(TrueHeading, 1, 0) & Chr(176) & " (true north)"
    Else
    '    lblHeading.Text = NumberFormat(MagneticHeading, 1, 0) & Chr(176) & " (magnetic)"
    End If
   
End Sub
Sub LocManager_AllowCalibration As Boolean
    Return
End Sub

Private Sub LocManager_LocationError
    Log("Error: " & LastException.Description)
End Sub


Could someone explain, why Apple is not happy with my app?

I didn't understand this point:

******************
You may wish to use the significant-change location service or the region monitoring location service if persistent real-time location updates are not required for your app features.
******************

Thanks in advance!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

b4xscripter

Member
Licensed User
Longtime User
Thank you a lot, dear Erel!
I just wrote an appeal explaining what is the main of my app.
Do you think I could provide a code? Tha problem is that I think that Apple reviewers would not understand our beautiful B4I coding....
Thank you!
 
Upvote 0

b4xscripter

Member
Licensed User
Longtime User
Erel!!!!!
Apple, once I exposed my arguments, finally accepted the app in App Store!
Thank you for your help!!!!!
Best regards
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Erel!!!!!
Apple, once I exposed my arguments, finally accepted the app in App Store!
Thank you for your help!!!!!
Best regards
I have had a few rejections due to reviewers not properly understanding the functionality or context of some of my apps. In every case (except one) I have found that contacting them with an explanation results in the app being approved. The exception was when my Five Dice (Yahtzee) app was rejected for having "Russian Roulette" mode (which is simply one roll per turn). Their argument was that it "depicted the use of weapons" & "encouraged reckless or unsafe behavior". Despite lodging an appeal, I could not make them see that the app is a dice game & they were not reviewing it in that context. In the end I had to change it to "Roulette" mode...

- Colin.
 
Upvote 0
Top