Skip to content

Instantly share code, notes, and snippets.

View marchbold's full-sized avatar
🚲
making stuff...

Michael marchbold

🚲
making stuff...
View GitHub Profile
@marchbold
marchbold / distriqt.extension.location.stopLocationMonitoring.as
Created July 12, 2016 01:42
Stop monitoring location updates using the Location ANE
Location.service.removeEventListener( LocationEvent.UPDATE, location_updateHandler );
var success:Boolean = Location.service.stopLocationMonitoring();
// com.distriqt.Location
@marchbold
marchbold / distriqt.extension.location.startLocationMonitoring.as
Last active July 12, 2016 01:41
Start monitoring location updates using the Location ANE
Location.service.addEventListener( LocationEvent.UPDATE, location_updateHandler );
var request:LocationRequest = new LocationRequest();
request.accuracy = LocationRequest.ACCURACY_NEAREST_TEN_METERS;
request.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
var success:Boolean = Location.service.startLocationMonitoring( request );
...
@marchbold
marchbold / distriqt.extension.location.infoAdditions.xml
Created July 12, 2016 01:22
InfoAdditions for iOS when using the Location ANE
<key>UIDeviceFamily</key>
<array>
<string>1</string>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>location-services</string>
</array>
@marchbold
marchbold / distriqt.extension.location.manifestAdditions.xml
Last active September 9, 2016 00:05
Manifest additions for the Location ANE
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<receiver android:name="com.distriqt.extension.location.receivers.GeofenceTransitionReceiver">
@marchbold
marchbold / distriqt.extension.location.requestAuthorisation.as
Last active August 22, 2016 03:04
Requesting access to device location using the Location ANE
switch (Location.service.authorisationStatus())
{
case AuthorisationStatus.ALWAYS:
case AuthorisationStatus.IN_USE:
trace( "User allowed access: " + Location.service.authorisationStatus() );
break;
case AuthorisationStatus.NOT_DETERMINED:
case AuthorisationStatus.SHOULD_EXPLAIN:
Location.service.requestAuthorisation( AuthorisationStatus.ALWAYS );
@marchbold
marchbold / distriqt.extension.message.sendEmail.as
Created July 5, 2016 05:12
Sending an Email using the Message ANE
if (Message.isMailSupported)
{
var email:String = "[email protected]";
var subject:String = "Sending HTML email from AIR using the distriqt Message ANE";
var body:String =
"<div>"+
"<p>This HTML email was sent using the distriqt <b>Message ANE</b></p>"+
"A link: <a href='http://airnativeextensions.com'>airnativeextensions.com</a>"+
"<br/>" +
@marchbold
marchbold / distriqt.extension.message.sendSMSWithUI.as
Created July 5, 2016 05:08
Sending an SMS with the distriqt Message ANE
if (Message.isSMSSupported)
{
Message.service.addEventListener( MessageSMSEvent.MESSAGE_SMS_CANCELLED, smsEventHandler );
Message.service.addEventListener( MessageSMSEvent.MESSAGE_SMS_SENT, smsEventHandler );
Message.service.addEventListener( MessageSMSEvent.MESSAGE_SMS_SENT_ERROR, smsEventHandler );
var sms:SMS = new SMS();
sms.address = "0444444444";
sms.message = "Sending an SMS with the distriqt Message ANE";
@marchbold
marchbold / distriqt.extension.message.manifestAdditions.xml
Last active July 5, 2016 05:12
Manifest Additions for Message ANE on Android
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application>
@marchbold
marchbold / distriqt.extension.gameservices.savedgames.deleteGame.as
Created July 4, 2016 01:41
Delete a saved game using the Game Services ANE
var savedGame:SavedGame = ...; // This should be a reference to a saved from returned from a load or open
GameServices.service.savedGames.addEventListener( SavedGamesEvent.DELETE_SUCCESS, savedGamesDeleteSuccessHandler );
GameServices.service.savedGames.addEventListener( SavedGamesEvent.DELETE_ERROR, savedGamesDeleteErrorHandler );
GameServices.service.savedGames.deleteGame( savedGame );
...
private function savedGamesDeleteSuccessHandler( event:SavedGamesEvent ):void
@marchbold
marchbold / distriqt.extension.gameservices.savedgames.saveGame.as
Created July 4, 2016 01:37
Saving game data using the Game Services ANE
var savedGame:SavedGame = ...; // This should be the currently opened user saved game
// Some game data
var data:String = "<game><a>data</a><b>"+Math.random().toPrecision(5)+"</b></game>";
// Change the description of the saved game
savedGame.description = "Saved game " + String( 1000 * Math.random());
// Write the new data
savedGame.data.clear();