Oracle Help Center | Oracle Push Cloud Service (Standalone) title

Location-based Push

Prerequisites

  1. Insert the PushIOManager framework and your pushio_config_debug.json (Development) or pushio_config.json (Distribution) in your project.
  2. Ensure that the CoreLocation framework has been added to your project as well.
  3. Add the -ObjC and -all_load linker flags to the Other Linker Flags section in Xcode - this is necessary or your application won't target the CoreLocation frameworks properly:

"Adding other linker flags to project in Xcode"

Once these steps have been taken, add the necessary code in your project to enable PushIOManager to begin tracking location.

NOTE: PushIOManager's location tracking uses Apple's Significant Change functionality by default.

Integrating Location Code

[1] Import the location manager in your AppDelegate.h file:

#import <PushIOManager/PushIOManager+PushIOLocation.h>
        
import PushIOManager
        

NOTE: The #import <PushIOManager/PushIOManager.h> statement can be deleted, as the location header file also contains code from the basic PushIOManager (hence PushIOManager+PushIOLocation.h).

[2] On the @interface line in AppDelegate.h, target the PushIOManagerLocationDelegate. This can replace the basic PushIOManagerDelegate, as this delegate will handle those tasks as well:

"Xcode screen, integrating the location code"

[3] In the AppDelegate.m file, tell the application to begin tracking location on start-up (didFinishLaunchingWithOptions):

[[PushIOManager sharedInstance] startUpdatingLocationForPush];
        
PushIOManager.sharedInstance().startUpdatingLocationForPush()
        

Tip: The top portion of your AppDelegate.m file should look something like this:

Screenshot of AppDelegate.m file with Objective-c location code
Screenshot of AppDelegate.m file with Swift location code

[4] Mandatory: Add one of two lines to your Info.plist for necessary Location support, depending on the use-case of your application:

NSLocationWhenInUseUsageDescription - "Location Description When In Use"
NSLocationAlwaysUsageDescription - "Location Description Always In Use"

For example,

"NSLocationWhenInUseUsageDescription setting screen shot"

This concludes basic setup for location-based push notifications. On first start-up, your device should ask if you would like to enable location services for your application.


Sending Location Pushes

Example cURL Command for Location Push:

curl "https://api.pushio.com/api/v1/notify_app/<APP_ID>/<SENDER_SECRET>" -d 'payload={"message":"Test"}&location_query={"reg":{"lat":<LATITUDE>,"lon":<LONGITUDE>,"dist":<RANGE_OF_SEARCH_IN_KILOMETERS>}}&audience=broadcast'

Replace the bolded items with your Application ID, Sender Secret, as well as Latitude and Longitude and Distance-From-A-Point data.

For example, this cURL Command is configured to send a notification to anyone within 0.5 kilometers of the Oracle office in Broomfield, CO (39.921544,-105.125026):

curl "https://api.pushio.com/api/v1/notify_app/aBcDefGhIJ/abCdEFGhIjKLmNoPqRSt" -d 'payload={"message":"You are near Oracle!"}&location_query={"reg":{"lat":39.921544,"lon":-105.125026,"dist":0.5}}&audience=broadcast'