Release Notes: (1.4.7)
  • Added iOS arm64 architecture support.

Integration Guide - Native Toolbox Plugin

Platforms: Android & iOS
Plugin version: 1.4.7

Follow a few steps below to get the plugin integrated in your App in minutes:

[1] Import the NativeToolbox[Android|IOS|Universal].unitypackage file to your project;

· >>> For Android platform, click on the menu item of Unity top menu bar: NeatPlug -> NativeToolbox -> Patch Android Configuration. This is for generating a valid AndroidManifest.xml or patching the existing file with NativeToolbox support.


· >>> For iOS platform, click on the menu item of Unity top menu bar: NeatPlug -> NativeToolbox -> Patch iOS Configuration. This is for automatically adding iOS SDK frameworks, libraries or patching the Info.plist file (if needed) as long as the Xcode project is generated by Unity.

[2] Find NativeToolboxAgent Prefab and NativeToolbox***Listener Prefabs in Assets/Plugins/NeatPlug/IAP/Native/Toolbox/Prefabs/, open the first scene of your game, drag & drop the necessary prefabs into the scene. (NOTE: NativeToolboxAgent is always required, other prefabs are listener prefabs that are needed in case you require the corresponding features. e.g. the NativeGeoKitListener should be selected if you want to get notified with GeoKit events, like the GPS location updates events).

[2] Integration is done here, see below HOWTOs to get started.

 
 

================================ [SystemKit : HOWTO] ============================ [TOP]

SystemKit enables you to get the following native device information:

· Android ID

· Device ID

· Sim Serial Number

· Sim Operator Name

Also SystemKit enables you to acquire a system wake lock to keep the screen on:

· AcquireWakeLock

· ReleaseWakeLock

Call the following static methods of NativeToolbox.SystemKit to use above features. i.e. NativeToolbox.SystemKit.methodName();

public static string GetAndroidId()
/**
 * Get the Android ID. 
 *          
 */
public static string GetAndroidId()
public static string GetDeviceId()
/**
 * Get the Device ID. 
 *          
 */
public static string GetDeviceId()
public static string GetSimSerialNumber()
/**
 * Get the Sim Serial Number. 
 *
 * NOTE: This information may be unavailable on some devices.
 *          
 */
public static string GetSimSerialNumber()
public static string GetSimOperatorName()
/**
 * Get the Sim Operator Name. 
 *
 * NOTE: This information may be unavailable on some devices.
 *          
 */
public static string GetSimOperatorName()
public static void AcquireWakeLock()
/**
 * Acquire a system wake lock to keep the screen on. 
 *          
 */
public static void AcquireWakeLock()
public static void ReleaseWakeLock()
/**
 * Release the acquired wake lock. 
 *          
 */
public static void ReleaseWakeLock()
 

================================ [DialogKit : HOWTO] ============================ [TOP]

DialogKit enables you to create the following native prompts or dialogs:

· Message Balloon

· Message Box

· Text Input Dialog

· Login Dialog

· Open Web Confirm Dialog

· Progress Dialog

Call the following static methods of NativeToolbox.DialogKit to create above objects. i.e. NativeToolbox.DialogKit.methodName();

public static void CreateMessageBalloon(string text, ... )
/**
 * Create a message balloon.
 * 
 * @param text
 *           string - text to be shown on the balloon.
 * 
 * @param duration
 *           BalloonDuration - the balloon duration.
 * 
 * @param layout
 *           UILayout - layout for placing the balloon.
 * 
 * @param xMargin
 *           int - horizontal margin
 * 
 * @param yMargin 
 *           int - vertical margin
 * 	
 */
public static void CreateMessageBalloon(string text, BalloonDuration duration, UILayout layout, 
                                        int xMargin, int yMargin)
public static void CreateMessageBox(string id, string title, string message, ... )
/**
 * Create a message box.
 * 
 * This is a flexible message box which you can use to
 * present an alert dialog, "Rate It" dialog, confirmation dialog, and more...
 * 
 * There are 3 buttons can be defined and shown up on the dialog :
 * (1) Positive Button, like "OK", "Yes", "Agree", "Like" ...
 * (2) Neutral Button, like "Just so so", "No comment" ...
 * (3) Negative Button, like "Cancel", "No", "Disagree", "Dislike" ...
 * You can customize the button captions, the dialog icon, the title, and 
 * the message.	 
 * 
 * Below button captions can be set to system-defined button captions: 
 * (1) BTN_CAP_SYS_OK
 * (2) BTN_CAP_SYS_CANCEL
 * (3) BTN_CAP_SYS_YES
 * (4) BTN_CAP_SYS_NO
 * NOTE: On Android systems, there is an issue may mislead users: 
 *       SYS_YES and SYS_NO still show the strings of SYS_OK and SYS_CANCEL.
 *       See: http://code.google.com/p/android/issues/detail?id=3713 
 *       It is suggested that you use literal "Yes" and "No" to make it 
 *       right on all platforms.
 * 
 * @param id
 *         string - the unique id of the dialog, 
 *                  you should set it to get notified with
 *                  UI events (e.g. OnClick)
 * 
 * @param title
 *            string - dialog title
 * 
 * @param message
 *            string - message to be shown on the dialog
 * 
 * @param icon 
 *          DialogIconType - the icon of the dialog
 * 
 * @param positiveButtonCaption
 *            string - positive button caption
 * 
 * @param neutralButtonCaption
 *            string - neutral button caption
 * 
 * @param negativeButtonCaption
 *            string - negative button caption
 * 		
 */
public static void CreateMessageBox(string id, string title, string message, 
                                    DialogIconType icon, string positiveButtonCaption, 
                                    string neutralButtonCaption, string negativeButtonCaption)
public static void CreateTextInputDialog(string id, string title, string message, ... )
/**
 * Create a text input dialog.
 * 
 * @param id
 *         string - the unique id of the dialog
 *		
 * @param title
 *            string - dialog title
 * 
 * @param message
 *            string - message to be shown on the dialog
 * 
 * @param icon 
 *           DialogIconType - the icon of the dialog
 *  	
 */
public static void CreateTextInputDialog(string id, string title, string message, 
                                         DialogIconType icon)
public static void CreateLoginDialog(string id, string title, string message, ... )
/**
 * Create a login dialog.
 * 
 * @param id
 *         string - the unique id of the dialog	 
 * 
 * @param title
 *            string - Login dialog title
 * 
 * @param message
 *            string - Login dialog message (optional)
 * 
 * @param usernameCaption
 *                    string - the caption of the username label
 * 
 * @param passwordCaption
 *                    string - the caption of the password label
 * 
 * @param loginButtonCaption
 *                    string - the caption of the login button
 * 
 * @param cancelButtonCaption
 *                    string - the caption of the cancel button	
 * 
 */	
public static void CreateLoginDialog(string id, string title, string message, 
                                     string usernameCaption, string passwordCaption,
                                     string loginButtonCaption, string cancelButtonCaption)
public static void CreateOpenWebConfirmDialog(string id, string title, string message, string url, ... )
/**
 * Create an open web confirm dialog.
 * 
 * @param id
 *         string - the unique id of the dialog	
 * 
 * @param title
 *            string - dialog title
 * 
 * @param message
 *            string - message to be shown on the dialog
 * 
 * @param url
 *            string - the url to be opened
 * 
 *  @param icon 
 *           DialogIconType - the icon of the dialog 
 *  	
 */
public static void CreateOpenWebConfirmDialog(string id, string title, string message, 
                                                    string url, DialogIconType icon)
public static void CreateProgressDialog(string id, string title, string message, ... )
/**
 * Create a progress dialog.
 * 
 * @param id
 *         string - the unique id of the dialog	
 * 
 * @param title
 *            string - dialog title
 * 
 * @param message
 *            string - message to be shown on the dialog		
 *  	
 */
public static void CreateProgressDialog(string id, string title, string message)
public static void DismissProgressDialog(string id)
/**
 * Dismiss a progress dialog
 *
 * @param id
 *       string - the unique id of the dialog
 * 
 */
public static void DismissProgressDialog(string id)

To receive the user input events, you should select the dropped NativeToolboxDialogKitListener gameObject, locate the NativeToolboxDialogKitListener.cs script, open it and make some modifications:

These callbacks are exposed in the script, you can supply your own implementations in them:

void OnMessageBoxPositiveButtonClicked(string id) { ... }
/**
 * Fired when the positive button on the message box is clicked.
 *
 * @param id
 *         string - unique identifier of created message box, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateMessageBox(id, ...)
 *                  method to create a message box. 
 */
void OnMessageBoxPositiveButtonClicked(string sku)
{
    /// Your code here...   
}
void OnMessageBoxNeutralButtonClicked(string id) { ... }
/**
 * Fired when the neutral button on the message box is clicked.
 *
 * @param id
 *         string - unique identifier of created message box, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateMessageBox(id, ...)
 *                  method to create a message box. 
 */
void OnMessageBoxNeutralButtonClicked(string id)
{
    /// Your code here...
}
void OnMessageBoxNegativeButtonClicked(string id) { ... }
/**
 * Fired when the negative button on the message box is clicked.
 *
 * @param id
 *         string - unique identifier of created message box, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateMessageBox(id, ...)
 *                  method to create a message box. 
 */
void OnMessageBoxNegativeButtonClicked(string id)
{
    /// Your code here...   
}
void OnTextInputDialogOKButtonClicked(string id, string input) { ... }
/**
 * Fired when the Ok button on the Text Input Dialog is clicked.
 *
 * @param id
 *         string - unique identifier of created dialog, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateTextInputDialog(id, ...)
 *                  method to create a text input dialog. 
 * 
 * @param input
 *         string - the user input.
 */
void OnTextInputDialogOKButtonClicked(string id, string input)
{
    /// Your code here...   
}
void OnTextInputDialogCancelButtonClicked(string id) { ... }
/**
 * Fired when the Cancel button on the Text Input Dialog is clicked.
 *
 * @param id
 *         string - unique identifier of created dialog, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateTextInputDialog(id, ...)
 *                  method to create a text input dialog. 
 */
void OnTextInputDialogCancelButtonClicked(string id)
{
    /// Your code here...   
}
void OnLoginDialogOKButtonClicked(string id, string username, string password) { ... }
/**
 * Fired when the Ok button on the Login Dialog is clicked.
 *
 * @param id
 *         string - unique identifier of created dialog, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateLoginDialog(id, ...)
 *                  method to create a user login dialog. 
 * 
 * @param username
 *         string - user-entered username
 * 
 * @param password
 *         string - user-entered password
 */
void OnLoginDialogOKButtonClicked(string id, string username, string password)
{
    /// Your code here...   
}
void OnLoginDialogCancelButtonClicked(string id) { ... }
/**
 * Fired when the Cancel button on the Login Dialog is clicked.
 *
 * @param id
 *         string - unique identifier of created dialog, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateLoginDialog(id, ...)
 *                  method to create a user login dialog. 
 */
void OnLoginDialogCancelButtonClicked(string id)
{
    /// Your code here...   
}
void OnOpenWebConfirmDialogOKButtonClicked(string id) { ... }
/**
 * Fired when the Ok button on the Open Web Confirm Dialog is clicked.
 *
 * @param id
 *         string - unique identifier of created dialog, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateOpenWebConfirmDialog(id, ...)
 *                  method to create a dialog to let the user confirm before opening
 *                  a web view. 
 */
void OnOpenWebConfirmDialogOKButtonClicked(string id)
{
    /// Your code here...   
}
void OnOpenWebConfirmDialogCancelButtonClicked(string id) { ... }
/**
 * Fired when the Cancel button on the Open Web Confirm Dialog is clicked.
 *
 * @param id
 *         string - unique identifier of created dialog, 
 *                  the id is set by yourself when you call 
 *                  NativeToolbox.DialogKit.CreateOpenWebConfirmDialog(id, ...)
 *                  method to create a dialog to let the user confirm before opening
 *                  a web view. 
 */
void OnOpenWebConfirmDialogCancelButtonClicked(string id)
{
    /// Your code here...   
}
 

============================= [WebKit : HOWTO] ============================= [TOP]

WebKit enables you to utilize the following telephony features:

· OpenWebView

Call the following static methods of NativeToolbox.WebKit to use above features. i.e. NativeToolbox.WebKit.methodName();

public static void OpenWebView(string url)
/**
 * Open a web view.
 * 
 * @param string
 *           url - The url to be opened.		
 */
public static void OpenWebView(string url)
public static void OpenEmbeddedWebView(string url, float widthScale,  float heightScale, ... )		
/**
 * Open an embedded web view.
 * 
 * @param string
 *           url - The url to be opened.	
 * 
 * @param float
 *           widthScale - The scale of the width. (0 - 1)
 * 
 * @param string
 *           heightScale - The scale of the height. (0 - 1)
 * 
 * @param WebViewLayout
 *           layout - The layout of the webview.
 * 
 * @param bool
 *           shouldSavePassword - True for save, false for not.
 * 
 * @param bool
 *           shoudSaveFormData - True for save, false for not.
 * 
 */
public static void OpenEmbeddedWebView(string url, float widthScale,  float heightScale, 
                                WebViewLayout layout, bool shouldSavePassword, bool shoudSaveFormData)
public static void CloseEmbeddedWebView()
/**
 * Close the embedded web view.	
 */
public static void CloseEmbeddedWebView()

To handle the web kit relevant events, you should drop NativeToolboxWebKitListener prefab into your first scene, locate the NativeToolboxWebKitListener.cs script, open it and make some modifications:

These callbacks are exposed in the script, you can supply your own implementations in them:

void OnLinkTappedInWebView(string link) { ... }
/**
 * Fired when a link is tapped through in web view.
 * 
 * @param string
 *          link - The link that is tapped by the user.
 */
void OnLinkTappedInWebView(string link)
{
    /// Your code here...   
}
void OnFunctionCalledFromJSInWebView(string method, string param) { ... }
/**
 * Fired when a function call from JS in web view received.
 * 
 * @param string
 *          method - The method to be called.
 * 
 * @param string
 *          param - The parameter attached to the function call.
 */
void OnFunctionCalledFromJSInWebView(string method, string param)
{
    /// Your code here...
}
 

================================ [GeoKit : HOWTO] ============================== [TOP]

GeoKit enables you to utilize the following GPS features:

· Get notified with device location updates

· Spot a given location (latitude, longitude) on Google Map

Call the following static methods of NativeToolbox.GeoKit to use above features. i.e. NativeToolbox.GeoKit.methodName();

public static void SpotLocationOnMap(string latitude, string longitude, ... )
/**
 * Spot the location on google map with location marker.
 * 
 * @param longitude
 *             string - the longitude of the specified location
 *            
 * @param latitude
 *             string - the latitude of the specified location 
 * 
 * @param label
 *            string - the label of the location to be shown on the map
 *           
 */
public static void SpotLocationOnMap(string latitude, string longitude, string label = null)
public static void SubscribeLocationUpdates()
/**
 * Subscribe the device location updates.
 * 
 * This enables device GPS location updates receiver.
 */
public static void SubscribeLocationUpdates()
public static void UnsubscribeLocationUpdates()
/**
 * Unsubscribe the device location updates.
 * 
 * This disables device GPS location updates receiver.
 */
public static void UnsubscribeLocationUpdates()

To receive geo relevant events, you should select the dropped NativeToolboxGeoKitListener gameObject, locate the NativeToolboxGeoKitListener.cs script, open it and make some modifications:

These callbacks are exposed in the script, you can supply your own implementations in them:

void OnGPSLocationChanged(double latitude, double longitude) { ... }
/**
 * Fired when the GPS location changed.	
 * 
 * @param latitude
 *         double - the latitude of the location.
 * 
 * @param langitude
 *         double - the longitude of the location.
 * 
 */
void OnGPSLocationChanged(double latitude, double longitude)
{
    /// Your code here...   
}
void OnGPSProviderDisabled(string provider) { ... }
/**
 * Fired when the GPS provider disabled.	
 * 
 * @param provider
 *         string - the GPS provider.
 */
void OnGPSProviderDisabled(string provider)
{
    /// Your code here...   
}
void OnGPSProviderEnabled(string provider) { ... }
/**
 * Fired when the GPS provider enabled.	
 * 
 * @param provider
 *         string - the GPS provider.
 */
void OnGPSProviderEnabled(string provider)
{
    /// Your code here...   
}
void OnGPSStatusChanged(string provider, string status) { ... }
/**
 * Fired when the GPS status changed.	
 * 
 * @param provider
 *         string - the GPS provider.
 */
void OnGPSStatusChanged(string provider, string status)
{
    /// Your code here...   
}
 

============================= [TelephonyKit : HOWTO] ============================= [TOP]

TelephonyKit enables you to utilize the following telephony features:

· Show Dial Keypad

· Call Phone

Call the following static methods of NativeToolbox.TelephonyKit to use above features. i.e. NativeToolbox.TelephonyKit.methodName();

public static void ShowDialKeypad(string number)
/**
 * Show the dial keypad.
 * 
 * @param number
 *            string - the phone number to dial	
 *         
 */
public static void ShowDialKeypad(string number = null)
public static void CallPhone(string number)
/**
 * Call the phone number.
 * 
 * @param number
 *            string - the phone number to call	
 *            
 */
public static void CallPhone(string number)
 

=============================== [MessagingKit : HOWTO] =========================== [TOP]

MessagingKit enables you to utilize the following messaging features:

· Show the SMS Composer

· Send a SMS in the background

· Show the MMS Composer

· Show the Email Composer

Call the following static methods of NativeToolbox.MessagingKit to use above features. i.e. NativeToolbox.MessagingKit.methodName();

public static void ShowSMSComposer(string number, string text = null)
/**
 * Show SMS composer.	
 * 
 * @param number
 *             string - the phone number to send SMS to
 * @param text
 *            string - SMS text to be sent
 *
 */
public static void ShowSMSComposer(string number, string text = null)
public static void SendSMS(string number, string text)
/**
 * Send SMS in the background.
 * 
 * To receive the delivery status of the SMS, you need to
 * drag & drop NativeToolboxAgent and NativeToolboxMessagingKitListener
 * prefabs to your first scene.
 *
 * The SMS delivery result will be returned via event:
 * NativeToolboxMessagingKitListener::OnSmsDelivered when succeeded or
 * NativeToolboxMessagingKitListener::OnFailedToDeliverSms when failed.
 * 
 * @param number
 *           string - the phone number to send SMS to	
 * @param text
 *           string  - SMS text to be sent
 *         
 */
public static void SendSMS(string number, string text)
public static void ShowMMSComposer(string number, string mediaFile, ... )
/**
 * Show MMS composer.
 * 
 * @param number
 *            string - the phone number to send MMS message to	
 * @param mediaFile
 *            string - the media file to be attached (e.g. "/sdcard/somepic.png")
 * @param subject
 *            string - MMS subject
 * @param text
 *            string - text body            
 *        
 */
public static void ShowMMSComposer(string number, string mediaFile, 
                                   string subject = null, string text = null)
public static void ShowEmailComposer(string to, string cc, string bcc, string subject, string body, ... )
/**
 * Show email composer.
 * 
 * @param to
 *          string - the recipient addresses to send email to (comma-saperated)
 * @param cc
 *          string - the cc addresses to send email to (comma-saperated)
 * @param bcc
 *          string - the bcc addresses to send email to (comma-saperated)
 * @param subject
 *          string - the email subject
 * @param body
 *          string - the email text body
 * @param attachment
 *          string - the email attachment path (e.g. "/sdcard/somepic.jpg")          
 *         
 */
public static void ShowEmailComposer(string to = null, string cc = null, string bcc = null,
                         string subject = null, string body = null, string attachment = null)
 

================================ [MediaKit : HOWTO] ============================= [TOP]

MediaKit enables you to utilize the following multi-media features:

· Play a media (audio / video)

· Explore all audio files on the device

· Explore all video files on the device

Call the following static methods of NativeToolbox.MediaKit to use above features. i.e. NativeToolbox.MediaKit.methodName();

public static void PlayMedia(string mediaFile)
/**
 * Play a media file (audio or video).
 * 
 * @param mediaFile
 *             string - absolute path of the media file to play	
 *                      (e.g. "/sdcard/somemedia.mp3")
 *          
 */
public static void PlayMedia(string mediaFile)
public static void ExploreAudioFiles()
/**
 * Explore the media store on the device and get all audio files information.
 *
 * The query result will be sent to NativeToolboxMediaKitListener::OnAudioItemInfoArrived event handler. 
 *
 * You can play the audio file by calling NativeToolbox.MediaKit.PlayMedia(audioInfo.uri); 
 * (audioInfo is an AudioFileInfo object which is passed to OnAudioItemInfoArrived() event handler).
 *          
 */
public static void ExploreAudioFiles()
public static void ExploreVideoFiles()
/**
 * Explore the media store on the device and get all video files information.
 *
 * The query result will be sent to NativeToolboxMediaKitListener::OnVideoItemInfoArrived event handler. 
 *
 * You can play the video file by calling NativeToolbox.MediaKit.PlayMedia(videoInfo.uri); 
 * (videoInfo is a VideoFileInfo object which is passed to OnVideoItemInfoArrived() event handler).
 *          
 */
public static void ExploreVideoFiles()
public static void CaptureScreenShot(string fileName = null)
/**
 * Capture a screen shot and save it on device persistent data storage.
 * 
 * You app will get notified by NativeToolboxMediaKitListener::OnScreenShotCaptured()
 * when the capture completed.
 * 
 * @param string
 *          fileName - The screen shot file name, if you leave this null,
 *                     the plugin will create a random filename for you.
 *          
 */
public static void CaptureScreenShot(string fileName = null)
public static void ShareScreenShot()
/**
 * Capture a screen shot and share it.       
 */
public static void ShareScreenShot()
public static void ShareImage(string fileName)
/**
 * Share an image that is saved on device persistent data storage.
 * 
 * The file should be saved in Application.persistentDataPath.
 * 
 * @param string
 *          fileName - The image file name.
 *          
 */
public static void ShareImage(string fileName)
public static void ScanSingleNewMedia(string mediaFile)
/**
 * Scan a newly added media file and add it to device gallery instantly.
 *
 * You app will get notified by NativeToolboxMediaKitListener::OnSingleNewMediaScanned()
 * when the scan completed.
 * 
 * @param string
 *            mediaFile - the media file to scan.		
 */
public static void ScanSingleNewMedia(string mediaFile)
public static void ScanAllNewMedia()
/**
 * Scan all newly added media files on pesistent storage and add them to media store.	
 *
 * NOTE: This method call is really expensive since all media files on the device
 * storage will be explored. It is strongly recommended that you should always
 * use ScanSingleNewMedia() instead.
 */
public static void ScanAllNewMedia()

To receive media relevant events, you should select the dropped NativeToolboxMediaKitListener gameObject, locate the NativeToolboxMediaKitListener.cs script, open it and make some modifications:

These callbacks are exposed in the script, you can supply your own implementations in them:

void OnAudioItemInfoArrived(NativeToolbox.AudioFileInfo audioInfo) { ... }
/**
 * Fired when the audio item information arrived.
 *
 * @param audioInfo
 *         NativeToolbox.AudioFileInfo - the audio file info object.
 *
 */
void OnAudioItemInfoArrived(NativeToolbox.AudioFileInfo audioInfo)
{
    /// Your code here...   
}
void OnVideoItemInfoArrived(NativeToolbox.VideoFileInfo audioInfo) { ... }
/**
 * Fired when the video item information arrived.
 *
 * @param audioInfo
 *         NativeToolbox.VideoFileInfo - the video file info object.
 *
 */
void OnVideoItemInfoArrived(NativeToolbox.VideoFileInfo audioInfo)
{
    /// Your code here...   
}

[EOF] If you encounter any problems while integrating the plugin, please do not hesitate to shoot us an email at support@neatplug.com, we will be helping you as soon as possible.Thanks for choosing NeatPlug solutions!