iOS Tutorial Inline Objective C code

moster67

Expert
Licensed User
Longtime User
I need to check an event using inline OBJC if it is possible.

Using the iLocation library and the Significant-Change Location Service (see my post here: https://www.b4x.com/android/forum/threads/background-location-tracking.50246/page-2#post-392042), it seems like I need to look out for an event which contains the UIApplicationLaunchOptionsLocationKey and then restart the Significant-Change Location Service (although from my test it seems to work nontheless). This is the information I found on Apple's web-site:


I tried with the following code:

B4X:
Sub LocManager_didFinishLaunchingWithOptions (myvalue As Boolean)

    'test code
    Dim status As String
    If myvalue Then
        Log("value is true")
        status = "It worked - value is True"
    Else
        Log("value is false")
        status = "It worked - value is False"
    End If

    Dim ln As Notification
    ln.Initialize(DateTime.Now + 5 * DateTime.TicksPerSecond)
    ln.AlertBody = "Starting message: " & status
    ln.Register
    'end test code

    If myvalue = True Then
        StartBackground(locManager, 0)
    Else
        'do something
    End If


End Sub




#If OBJC

#import "iCore.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSLog(@"didFinishLaunchingWithOptions");

        // When there is a significant changes of the location,
        // The key UIApplicationLaunchOptionsLocationKey will be returned from didFinishLaunchingWithOptions
        // When the app is receiving the key, it must reinitiate the locationManager and get
        // the latest location updates

        // This UIApplicationLaunchOptionsLocationKey key enables the location update even when
        // the app has been killed/terminated (Not in th background) by iOS or the user. It works also when device
        // has been rebooted.

        NSLog(@"UIApplicationLaunchOptionsLocationKey : %@" , [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]);

         [B4IObjectWrapper raiseEvent:self :@"_didFinishLaunchingWithOptions:" :@[]];
 
         if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]) return YES;
            return NO;
      
}
    
#end if

The code compiles (both in debug and release mode) but the LocManager_didFinishLaunchingWithOptions will not trigger.

Obviously I am doing something wrong. Are you able to help?
 
Last edited:

Ju Yang

Active Member
Licensed User
Longtime User
hello, can I use a third Party framework by inline object-c? I really need It
 

Ju Yang

Active Member
Licensed User
Longtime User
or, how can I build a framework into a b4i .a lib ? it is possible?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…