iOS Question is B4i compatible to the pushkit framework?

Eberhard

Member
Licensed User
Longtime User
Hello,

did not find any information about B4i using the Apple pushkit framework,
special how to implement the needed delegate callback functions.
Is it possible to use it and are there samples available about the implementation?

Many thanks in advance
 

Eberhard

Member
Licensed User
Longtime User
Thanks for your response,
I'am coding an VoIP app which is the user end part of an voice gateway to TETRA netzworks.
On android everything works fine without Push because communicating to the gateway server is not restricted in background.
On iPhone my only way to get the app definitly working also from background seems to be the VoIP Push messages.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Apple documentation is here: https://developer.apple.com/library.../Conceptual/EnergyGuide-iOS/OptimizeVoIP.html

There is currently no library for PushKit. If you are a bit familiar with Objective C then you can add the required code as an inline OBJC code.

You need to add #AdditionalLib: PushKit.framework
This will tell the compiler to add a reference to this framework.

Example of implementing a complete class with OBJC: https://www.b4x.com/android/forum/threads/ibeacons.79257/#content (note that first @end line).
 
Upvote 0

Eberhard

Member
Licensed User
Longtime User
It seems that my Objective C skills are not enough for this :-(
From the documentation it seems to me that only 3 routines has to be added to the delegate,
something I thought is like putting them into an OBJC block of the main module.
I then call the registration routine from Sub Application_Start() but there comes no callback with the token.
What am I doing wrong?

B4X:
Private Sub Application_Start (Nav As NavigationController)
    Dim no As NativeObject =Me
    no.RunMethod("voipRegistration",Null)
End Sub

#IF OBJC
#import <PushKit/PushKit.h>

// Register for VoIP notifications
- (void) voipRegistration {
   dispatch_queue_t mainQueue = dispatch_get_main_queue();
     PKPushRegistry * voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue]; // Create a push registry object
     voipRegistry.delegate = self; // Set the registry's delegate to self (self or self.bi?)
     voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; // Set the push type to VoIP
     NSLog(@"====voipRegistration);
}

// Handle updated push credentials
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials: (PKPushCredentials *)credentials forType:(NSString *)type {
   // Register VoIP push token (a property of PKPushCredentials) with server
     NSLog(@"token=%@ type=%@",credentials.token, type);
}

// Handle incoming pushes
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
  // Process the received push
  NSLog(@"====pushRegistry Receive");
   NSLog(@"%@",payload.description);
}

#End If
 
Upvote 0

Eberhard

Member
Licensed User
Longtime User
As an test I added the 3 routines above to an simple XCode project,
there it worked right after adding ,PKPushRegistryDelegate to the
@interface AppDelegate : UIResponder <UIApplicationDelegate>

Can this be realized this with B4i or isn't that possible with inline OBJC without creating an complete library?

Last month after some try and error I was able to implement the needed callbacks for audioqueues to record and playback using inline OBJC,
so hopefully im not unfit in creating such code.

Maybe I only need a hint or a trick or an similar example code.
(has not to be complete or tested)

Many thanks in advance
 
Upvote 0
Top