Press on the image to return to the main documentation page.
Parse
The Parse platform provides a complete backend solution for your mobile application. On Parse, you create an App for each of your mobile applications. Each App has its own application id and client key. Your account on Parse can accommodate multiple Apps. See the documentation on the Parse.com web site for more information. https://parse.com/docs/index
This library supports ParseObject, ParseQquery, ParseFile, ParseGeoPoint and Push Notifications.
All the operations which need to access the Parse online service are done asynchronously and raise events when complete whose parameters include a Success indication. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException. If necessary this should be processed in the event code as there is a possibility that a further error could occur in another asynchronous call that would overwrite the existing LastException.
Note that these asynchronous operations do not necessarily complete in the order in which they are invoked. To deal with this possibility a TaskID parameter is provided in each call that can be used, if required, to identify which of several possible method calls has just completed. This may not always be needed.
Copyright 2013 Anywhere Software
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This object has three methods. Initialize, which is required to Initialize the Parse library. TrackOpening allows openings of your applications to be recorded. EnableNotifications lets your application receive push notifications.
Disables receiving pushes sent to everyone If no channels are subscribed to it should stop the PushService.
EnableNotifications (ActivityNameAsClass)
Enable push notifications and cause the specified Activity to be opened when one is received. The push data may be obtained in the Activity from the StartingIntent ExtrasToString method. To enable push you also need to add the following to the Manifest Editor in the project.
The Activity named will be started for a push sent to everyone registered for push with the Parse application. The default application icon will be used for the notification. AddApplicationText(<serviceandroid:name="com.parse.PushService" />
<receiverandroid:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<actionandroid:name="android.intent.action.BOOT_COMPLETED" />
<actionandroid:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>) Object Browser does not show the actual XML text within AddApplicationText above. The XML is available for cut and paste in the first post of the Parse library forum thread
SetLoggingLevel (LogLevelAsInt)
This is included for diagnostic purposes only. You should not use this unless requested to.
Sets the level of logging to display, where each level includes all those below it. Ensure this is set to Parse.LOG_LEVEL_ERROR or Parse.LOG_LEVEL_NONE before deploying your app to ensure no sensitive information is logged. The default level is Parse.LOG_LEVEL_ERROR.
Call this function when the user should be subscribed to a new push channel. The default application icon will be used for the notification. The Activity named will be started for a push received for the specified channel.
Call this function when the user should be subscribed to a new push channel. The specified icon file from the application resources will be used for the notification. The Activity named will be started for a push received for the specified channel.
SubscriptionsAsString()
Accesses the current set of channels for which the current installation is subscribed.
TrackOpening
Enables tracking of launches of this application.
The following is a technical comment included as a point of record. trackAppOpened does not work as documented in the Parse API. It states that a null argument to ParseAnalytics.trackAppOpened will work, but the code checks for null and does not send the tracking data if the intent is null or if the intent extras are null. This method creates a new intent with putExtra("Data", "B4a_App") and sends that which seems to work OK.
Unsubscribe (ChannelAsString)
Call this function when the user should be unsubscribed from a push channel.
ParseFile is a local representation of a file that is saved to the Parse cloud. The workflow is to construct a ParseFile with data and a filename. Then save it and set it as a field on a ParseObject. You can also use it to store any binary data (up to 10 megabytes).
Permissions:
android.permission.INTERNET
Events:
DoneGet(Success As Boolean, Data() As Byte, TaskID As Int) DoneSave(Success As Boolean, TaskID as Int)
Gets the data for the object from the server. The DoneGet event will be raised when saving completes. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Initialize (SaveNameAsString, Data() AsByte)
Initializes the ParseFile with a name and the file data as a Byte array. Giving a SaveName with a proper file extension (e.g. ".png") is best because it allows Parse to deduce the content type of the file and set appropriate HTTP headers when it is fetched.
Initializes the ParseFile from a filename and path. Giving a SaveName with a proper file extension (e.g. ".png") is best because it allows Parse to deduce the content type of the file and set appropriate HTTP headers when it is fetched.
IsDataAvailableAsBoolean [read only]
Returns whether the file has available data.
IsDirtyAsBoolean [read only]
Returns whether the file still needs to be saved.
IsInitializedAsBoolean
NameAsString [read only]
Returns the file SaveName. Before Save is called, this is just the SaveName given by Initialize. After Save is called, that name gets prefixed with a unique identifier.
Save (EventNameAsString, TaskIDAsInt)
Saves the object on the server. The DoneSave event will be raised when saving completes. If you want to ignore the event then pass an empty String for EventName. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException. A ParseFile must be saved before it can be added to a ParseObject
URLAsString [read only]
This returns the url of the file. It's only available after you Save or after you get the file from a ParseObject.
ParseGeoPoint represents a latitude/longitude point that may be associated with a key in a ParseObject or used as a reference point for geo queries. This allows proximity based queries on the key.
Only one Key in a class may contain a GeoPoint.
Points should not equal or exceed the extreme ends of the allowable ranges. Latitude should not be -90.0 or 90.0. Longitude should not be -180.0 or 180.0. Attempting to set latitude or longitude out of bounds will cause an error.
The ParseObject is a local representation of data that can be saved and retrieved from the Parse cloud. The basic workflow for creating new data is to construct a new ParseObject, use Put() to fill it with data, and then use Save() to persist to the database. The basic workflow for accessing existing data is to use a ParseQuery to specify which existing data to retrieve.
Events:
DoneSave(Success As Boolean, TaskID As Int) DoneDelete(Success As Boolean, TaskID As Int) DoneRefresh(Success As Boolean, TaskID As Int)
Adds the provided Value to the array of values for Key. The first use of Add for a Key defines the Value of that Key as an array The array of values for a Key may be accessed by GetJSONArray.
ContainsKey (KeyAsString) AsBoolean
Returns True if the provided Key is present in the ParseObject.
CreatedAtAsLong [read only]
Returns the time when the data was first created on the Parse server. This reports time as the server sees it, so that if you create a ParseObject, then wait a while, and then call save(), the creation time will be the time of the first save() call rather than the time the object was created locally.
Creates a reference to an existing ParseObject for use in creating associations between ParseObjects. Calling IsDataAvailable on this object will return false until Refresh has been called. No network request will be made.
Delete (EventNameAsString, TaskIDAsInt)
Deletes the object from the server. The DoneDelete event will be raised when saving completes. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException. If you want to ignore the event then pass an empty String for EventName.
GetBoolean (KeyAsString) AsBoolean
Returns the Value of Key as a Boolean. Note that Key is case-sensitive.
GetDouble (KeyAsString) AsDouble
Returns the Value of Key as a Double. Note that Key is case-sensitive.
GetInt (KeyAsString) AsInt
Returns the Value of Key as an Int. Note that Key is case-sensitive.
GetJSONArray (KeyAsString) AsString
Returns the value of a Key as a JSON array or an empty string if the value is undefined. Note that Key is case-sensitive.
GetKeysAsString()
Returns a String array containing the names of the Keys in the ParseObject. Only the Keys with defined data values are returned.
GetLong (KeyAsString) AsLong
Returns the Value of Key as a Long.
GetObject (KeyAsString) AsObject
Returns the Value object for the specified Key. Note that Key is case-sensitive. In most cases it is more convenient to use a helper function such as GetString or GetInt. This is mostly for use with Byte arrays, ParseFile, ParseGeoPoint and ParseObject objects.
GetObjectType (KeyAsString) AsString
Returns the type name of the Value that is returned by GetObject for the specified Key. Note that Key is case-sensitive. This is provided for diagnostic purposes.
GetRelation (KeyAsString) AsParseRelation
Access or create a Relation value for a key. Returns the ParseRelation object if the relation already exists, or can be created, for the Key.
GetString (KeyAsString) AsString
Returns the Value of Key as a String. Note that Key is case-sensitive.
Increment (KeyAsString, NumberAsDouble)
Increment (or decrement) the value of the given Key by the amount Number.
Initialize (ClassNameAsString)
Initializes the ParseObject and sets the class name into which the Key Value pairs will be saved.
IsDataAvailableAsBoolean [read only]
Returns True if the ParseObject is new or has been fetched or refreshed. False otherwise.
IsInitializedAsBoolean
ObjectIdAsString [read only]
Returns the unique ObjectId for the ParseObject. An object id is assigned as soon as an object is saved to the server. The combination of a Class name and an ObjectId uniquely identifies an object in your application.
Put (KeyAsString, ValueAsObject)
Places the provided Key Value pair in the present ParseObject.
Refresh (EventNameAsString, TaskIDAsInt)
Refreshes the object by reading it from the server. The DoneRefresh event will be raised when the operation completes. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Save (EventNameAsString, TaskIDAsInt)
Saves the object on the server. The DoneSave event will be raised when saving completes. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException. If you want to ignore the event then pass an empty String for EventName.
UpdatedAtAsLong [read only]
Returns the time when the data was last updated on the Parse server. This reports time as the server sees it, so that if you make changes to a ParseObject, then wait a while, and then call save(), the updated time will be the time of the save() call rather than the time the object was changed locally.
A class that is used to access all of the children of a many-to-many relationship. Each instance of Parse.Relation is associated with a particular parent object and key. A ParseRelation is obtained by invoking GetRelation on a ParseObject.
Clears both expiration values, indicating that the notification should never expire.
Initialize
Initializes the ParsePush object. The default channel is the empty string, also known as the global broadcast channel, but this value can be overridden using SetChannel(String)
IsInitializedAsBoolean
Send (EventNameAsString, TaskIDAsInt)
Send the push notification. The DoneSend event will be raised when sending completes. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException. If you want to ignore the event then pass an empty String for EventName.
SetChannel (ChannelAsString)
Sets the channel on which this push notification will be sent.
SetExpirationTime (TimeTicksAsLong)
Sets the timestamp at which this notification should expire, in seconds (UTC). This notification will be sent to devices which are either online at the time the notification is sent, or which come online before the expiration time is reached. Because device clocks are not guaranteed to be accurate, most applications should instead use ParsePush.setExpirationTimeInterval. Note that the underlying ParsePush method wants a Unix time so this method takes an Android time in ticks and converts it.
SetExpirationTimeInterval (IntervalAsLong)
Sets the time interval after which this notification should expire, in seconds. This notification will be sent to devices which are either online at the time the notification is sent, or which come online within the given number of seconds of the notification being received by Parse's server. An interval which is less than or equal to zero indicates that the message should only be sent to devices which are currently online.
SetMessage (MessageAsString)
Sets the message that will be shown in the notification.
DoneGet(Success As Boolean, PO As ParseObject, TaskId As Int) DoneFind(Success As Boolean, ListOfPO As List, TaskId As Int) DoneCount(Success As Boolean, Count As Int, TaskId As Int)
Counts the number of objects matching the query. The DoneCount event will be raised when the operation completes. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Find (EventNameAsString, TaskIdAsInt)
Finds all objects matching the query. The DoneFind event will be raised when the operation completes. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Gets an object based on its ObjectId. The DoneGet event will be raised when the operation completes. If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Initialize (ClassNameAsString)
Initializes the object and sets the Class name.
IsInitializedAsBoolean
LimitAsInt [write only]
Limits the number of results. Pass -1 to retrieve all items.
OrderBy (KeyAsString, AscendingAsBoolean)
Sets the ordering of the query results as Ascending or Descending.
A class that is used to access all of the children of a many-to-many relationship. Each instance of Parse.Relation is associated with a particular parent object and key. A ParseRelation is obtained by invoking GetRelation on a ParseObject.