Please refer to this link for manual installation of Globe Connect iOS SDK.
Please refer to this link for Globe Connect iOS SDK installtion via CocoaPods.
If you haven't signed up yet, please follow the instructions found in Getting Started to obtain an App ID
and App Secret
these tokens will be used to validate most of your interaction requests with the Globe APIs.
The authenication process follows the protocols of **OAuth 2.0**. The example code below shows how you can swap your app tokens for an access token.
//
// sample implementation of login using the ViewController.swift file
//
import UIKit
import GlobeConnectIOS
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func loginViaGlobe(_ sender: Any) {
let authenticate = Authenticate()
authenticate.login(
viewController: self,
appId: "[app_id]",
appSecret: "[app_secret]",
success: { results in
// access token will returned here
print(results)
},
failure: { error in
print(error)
}
)
}
}
//
// Add the following code at the bottom of your AppDelegate.swift file.
// Make sure that a URL scheme is set for this to work.
//
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
if let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] {
if (String(describing: sourceApplication) == "com.apple.SafariViewService") {
let authenticate = Authenticate()
authenticate.listenForRequest(url: url)
return true
}
}
return true
}
{
"access_token":"1ixLbltjWkzwqLMXT-8UF-UQeKRma0hOOWFA6o91oXw",
"subscriber_number":"9171234567"
}
Short Message Service (SMS) enables your application or service to send and receive secure, targeted text messages and alerts to your Globe / TM subscribers.
Note: All API calls must include the access_token as one of the Universal Resource Identifier (URI) parameters.
Send an SMS message to one or more mobile terminals:
import GlobeConnect
let globeConnect = GlobeConnect(
shortCode: "[short_code]",
accessToken: "[access_token]"
)
connect.sendMessage(
address: "[subscriber_number]",
message: "[message]",
success: { json in
dump(json)
},
failure: { error in
print(error)
}
)
{
"outboundSMSMessageRequest": {
"address": "tel:+639175595283",
"deliveryInfoList": {
"deliveryInfo": [],
"resourceURL": "https://devapi.globelabs.com.ph/smsmessaging/v1/outbound/8011/requests?access_token=3YM8xurK_IPdhvX4OUWXQljcHTIPgQDdTESLXDIes4g"
},
"senderAddress": "8011",
"outboundSMSTextMessage": {
"message": "Hello World"
},
"receiptRequest": {
"notifyURL": "http://test-sms1.herokuapp.com/callback",
"callbackData": null,
"senderName": null,
"resourceURL": "https://devapi.globelabs.com.ph/smsmessaging/v1/outbound/8011/requests?access_token=3YM8xurK_IPdhvX4OUWXQljcHTIPgQDdTESLXDIes4g"
}
}
}
Send binary data through SMS:
import GlobeConnect
let globeConnect = GlobeConnect(
shortCode: "[short_code]",
accessToken: "[access_token]"
)
globeConnect.sendBinaryMessage(
address: "[subscriber_number]",
message: "[message]",
header: "[data_header]",
success: { json in
dump(json)
},
failure: { error in
print(error)
}
)
{
"outboundBinaryMessageRequest": {
"address": "9171234567",
"deliveryInfoList": {
"deliveryInfo": [],
"resourceURL": "https://devapi.globelabs.com.ph/binarymessaging/v1/outbound/{senderAddress}/requests?access_token={access_token}",
"senderAddress": "21581234",
"userDataHeader": "06050423F423F4",
"dataCodingScheme": 1,
"outboundBinaryMessage": {
"message": "samplebinarymessage"
},
"receiptRequest": {
"notifyURL": "http://example.com/notify",
"callbackData": null,
"senderName": null
},
"resourceURL": "https://devapi.globelabs.com.ph/binarymessaging/v1/outbound/{senderAddress}/requests?access_token={access_token}"
}
}
USSD are basic features built on most smart phones which allows the phone owner to interact with menu item choices.
The following example shows how to send a USSD request.
import GlobeConnect
let globeConnect = GlobeConnect(
shortCode: "[short_code]",
accessToken: "[access_token]"
)
globeConnect.sendUssdRequest(
address: "[subscriber_number]",
message: "[message]",
flash: [flash],
success: { json in
dump(json)
},
failure: { error in
print(error)
})
{
"outboundUSSDMessageRequest": {
"address": "639954895489",
"deliveryInfoList": {
"deliveryInfo": [],
"resourceURL": "https://devapi.globelabs.com.ph/ussd/v1/outbound/21589996/reply/requests?access_token=access_token"
},
"senderAddress": "21580001",
"outboundUSSDMessage": {
"message": "Simple USSD Message\nOption - 1\nOption - 2"
},
"receiptRequest": {
"ussdNotifyURL": "http://example.com/notify",
"sessionID": "012345678912"
},
"resourceURL": "https://devapi.globelabs.com.ph/ussd/v1/outbound/21589996/reply/requests?access_token=access_token"
}
}
The following example shows how to send a USSD reply.
import GlobeConnect
let globeConnect = GlobeConnect(
shortCode: "[short_code]",
accessToken: "[access_token]"
)
globeConnect.replyUssdRequest(
address: "[subscriber_number]",
message: "[message]",
sessionId: "[session_id]",
flash: [flash],
success: { json in
dump(json)
},
failure: { error in
print(error)
})
{
"outboundUSSDMessageRequest": {
"address": "639954895489",
"deliveryInfoList": {
"deliveryInfo": [],
"resourceURL": "https://devapi.globelabs.com.ph/ussd/v1/outbound/21589996/reply/requests?access_token=access_token"
},
"senderAddress": "21580001",
"outboundUSSDMessage": {
"message": "Simple USSD Message\nOption - 1\nOption - 2"
},
"receiptRequest": {
"ussdNotifyURL": "http://example.com/notify",
"sessionID": "012345678912",
"referenceID": "f7b61b82054e4b5e"
},
"resourceURL": "https://devapi.globelabs.com.ph/ussd/v1/outbound/21589996/reply/requests?access_token=access_token"
}
}
Your application can monetize services from customer's phone load by sending a payment request to the customer, in which they can opt to accept.
The following example shows how you can request for a payment from a customer.
import GlobeConnect
let globeConnect = GlobeConnect(
appId: "[app_id]",
appSecret: "[app_secret]",
accessToken: "[access_token]"
)
globeConnect.sendPaymentRequest(
amount: [amount],
description: "[description]",
endUserId: "[subscriber_number]",
referenceCode: "[reference]",
transactionOperationStatus: "[status]",
success: { json in
dump(json)
},
failure: { error in
print(error)
})
{
"amountTransaction":
{
"endUserId": "9171234567",
"paymentAmount":
{
"chargingInformation":
{
"amount": "0.00",
"currency": "PHP",
"description": "my application"
},
"totalAmountCharged": "0.00"
},
"referenceCode": "12341000023",
"serverReferenceCode": "528f5369b390e16a62000006",
"resourceURL": null
}
}
The following example shows how you can get the last reference of payment.
import GlobeConnect
let globeConnect = GlobeConnect(
appId: "[app_id]",
appSecret: "[app_secret]",
accessToken: "[access_token]"
)
globeConnect.getLastReferenceCode(
success: { json in
dump(json)
},
failure: { error in
print(error)
})
{
"referenceCode": "12341000005",
"status": "SUCCESS",
"shortcode": "21581234"
}
Amax is an automated promo builder you can use with your app to award customers with certain globe perks.
import GlobeConnect
let globeConnect = GlobeConnect(
appId: "[app_id]",
appSecret: "[app_secret]"
)
globeConnect.sendRewardRequest(
address: "[subscriber_number]",
promo: "[promo]",
rewardsToken: "[rewards_token]",
success : { json in
dump(json)
},
failure: { error in
print(error)
}
)
{
"outboundRewardRequest": {
"transaction_id": 566,
"status": "Please check your AMAX URL for status",
"address": "9065272450",
"promo": "FREE10MB"
}
}
To determine a general area (lat,lng) of your customers you can utilize this feature.
import GlobeConnect
let globeConnect = GlobeConnect(
accessToken: "[access_token]"
)
globeConnect.getLocation(
address: "[subscriber_number]",
success : { json in
dump(json)
},
failure: { error in
print(error)
})
{
"terminalLocationList": {
"terminalLocation": {
"address": "tel:9171234567",
"currentLocation": {
"accuracy": 100,
"latitude": "14.5609722",
"longitude": "121.0193394",
"map_url": "http://maps.google.com/maps?z=17&t=m&q=loc:14.5609722+121.0193394",
"timestamp": "Fri Jun 06 2014 09:25:15 GMT+0000 (UTC)"
},
"locationRetrievalStatus": "Retrieved"
}
}
}
Subscriber Data Query API interface allows a Web application to query the customer profile of an end user who is the customer of a mobile network operator.
The following example shows how you can get the subscriber balance.
import GlobeConnect
let globeConnect = GlobeConnect(
accessToken: "[access_token]"
)
globeConnect.getSubscriberBalance(
address: "[subscriber_number]",
success: { json in
dump(json)
},
failure: { error in
print(error)
})
{
"terminalLocationList":
{
"terminalLocation":
[
{
address: "639171234567",
subBalance: "60200"
}
]
}
}
The following example shows how you can get the subscriber reload amount.
import GlobeConnect
let globeConnect = GlobeConnect(
accessToken: "[access_token]"
)
globeConnect.getSubscriberReloadAmount(
address: "[subscriber_number]",
success: { json in
dump(json)
},
failure: { error in
print(error)
})
{
"terminalLocationList":
{
"terminalLocation":
[
{
address: "639171234567",
reloadAmount: "30000"
}
]
}
}