Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
rlepinski committed Jan 26, 2015
0 parents commit fda32f9
Show file tree
Hide file tree
Showing 201 changed files with 22,083 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
*.DS_STORE

[Ll]ibrary/
[Tt]emp/
[Oo]bj/

*/bin/*
*/jar/*
*.pyc
.settings/
local.properties
proguard/
*.swo
*.swp
reports/
*.iml
.idea/
.gradle
build/
4 changes: 4 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UA Developers:
Neel Banerjee
Chris Auel
Ryan Lepinski
13 changes: 13 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2015 Urban Airship and Contributors

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.
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
Urban Airship Unity Plugin
==========================

Urban Airship offers this code free of charge under the terms of the Apache 2.0 Open Source License. We offer no official support of this code; use of this code is not covered under existing support contracts.

Contributing Code
-----------------
We accept pull requests! If you would like to submit a pull request, please fill out and submit a
Code Contribution Agreement (http://urbanairship.com/legal/contribution-agreement/).

Third Party Packages
--------------------
- mod_pbxproj.py - Apache License, Copyright 2012 Calvin Rien

Setup
-----
1. Update gradle.properties with your app's configuration.
2. Install the Android SDK with the latest support repo and libaries installed.
3. Build the plugin with `./gradlew build`
4. Copy the output of build/unity-plugin/ into your unity app.

An example script is provided in 'Scripts/UrbanAirship.cs'. Import into your app's scripts and attach it to a game object in each scene. The script
shows a very basic integration with Urban Airship.

Known Issues
------------
- Landing Page does not pause the game on iOS.
- Analytics is not instrumented for Pre-ICS Android devices.
- The Unity Plugin will receive the entire push payload on iOS, while Android only sends the alert message.
- GetTags() is json encoded string.

Project Structure
-----------------
- *android-plugin*: The Android native unity plugin.
- *ios-plugin*: The iOS native unity plugin.
- *src*: The common unity plugin source.
- *Scripts*: Example scripts for the plugin.

Plugin Interface
---------------
The main plugin script can be found Assets/Plugins/UAirship.cs. It works for iOS and Android and will safely no-op on other platforms.

**public static void AddListener(GameObject gameObject)**
- Adds a game object to listen for push notification that were received in the foreground. The game object needs to implement OnPushReceived(string payload).

**public static void RemoveListener(GameObject gameObject)**
- Removes a game object from receiveing push notifications.

**public static string GetDeepLink(bool clear = true)**
- Gets the last triggered deep link if availble.
- clear: whether or not to clear the deep link.

**public static string GetIncomingPush(bool clear = true)**
- Gets the launch push if available.
- clear: whether or not to clear the push.

**public static bool IsPushEnabled()**
- Checks if push is enabled or not.

**public static void EnablePush()**
- Enables push notificaitons.

**public static void DisablePush()**
- Disables push notifications.

**public static void AddTag(string tag)**
- Adds a tag.

**public static void RemoveTag(string tag)**
- Removes a tag.

**public static string GetTags()**
- Gets the current device tags.
- The tags will be a json encoded array.

**public static void SetAlias(string alias)**
- Sets the alias.

**public static string GetAlias()**
- Gets the alias.

**public static string GetChannelId()**
- Gets the channel ID for device.

**public static bool IsLocationEnabled()**
- Checks if location is enabled or not.

**public static void EnableLocation()**
- Enables foreground location.

**public static void DisableLocation()**
- Disables foreground location.

**public static bool IsBackgroundLocationEnabled()**
- Checks if background location is enabled or not.

**public static void EnableBackgroundLocation()**
- Enables background location.

**public static void DisableBackgroundLocation()**
- Disables background location.


58 changes: 58 additions & 0 deletions Scripts/UrbanAirship.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright 2015 Urban Airship and Contributors
*/

using UnityEngine;
using System.Collections;

public class UrbanAirship : MonoBehaviour {

public string addTagOnStart;

void Awake()
{
UAirship.EnablePush ();
}

void Start()
{
UAirship.AddListener (gameObject);

if (!string.IsNullOrEmpty(addTagOnStart))
{
UAirship.AddTag(addTagOnStart);
}

CheckDeepLink ();
}

void OnDestroy()
{
UAirship.RemoveListener (gameObject);
}

void OnPushReceived(string payload)
{
Debug.Log ("Unity received push! " + payload);
}

void OnApplicationPause(bool pauseStatus) {
if (!pauseStatus)
{
CheckDeepLink();
}
}

void CheckDeepLink()
{
Debug.Log ("Checking for deeplink.");

string deepLink = UAirship.GetDeepLink();
if (!string.IsNullOrEmpty(deepLink))
{
Debug.Log ("Launched with deeplink! " + deepLink);

// Handle any deep links here
}
}
}
129 changes: 129 additions & 0 deletions android-plugin/AndroidManifest-template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:amazon="http://schemas.amazon.com/apk/res/android"
package="${applicationId}"
android:installLocation="preferExternal"
android:theme="@android:style/Theme.NoTitleBar"
android:versionCode="1"
android:versionName="1.0">


<!-- Urban Airship -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />

<permission android:name="${applicationId}.permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.RECEIVE_ADM_MESSAGE" />

<permission android:name="${applicationId}.permission.UA_DATA" android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.UA_DATA" />

<!-- OPTIONAL for location -->
<!-- uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<!-- End of Urban Airship -->


<supports-screens android:anyDensity="true" android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" />

<!-- Required to use UrbanAirshipApplication -->
<application
android:name="com.urbanairship.unityplugin.UrbanAirshipApplication"
android:debuggable="false"
android:icon="@drawable/app_icon"
android:label="@string/app_name">

<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale"
android:label="@string/app_name" android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik"
android:value="false" />
</activity>

<!-- Urban Airship -->
<activity android:name="com.urbanairship.actions.ActionActivity" />
<activity android:name="com.urbanairship.CoreActivity" />
<activity android:name="com.urbanairship.actions.LandingPageActivity" android:exported="false">
<intent-filter>
<action android:name="com.urbanairship.actions.SHOW_LANDING_PAGE_INTENT_ACTION" />
<data android:scheme="http" />
<data android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<receiver android:name="com.urbanairship.unityplugin.IntentReceiver" android:exported="false">
<intent-filter>
<action android:name="com.urbanairship.push.CHANNEL_UPDATED" />
<action android:name="com.urbanairship.push.OPENED" />
<action android:name="com.urbanairship.push.DISMISSED" />
<action android:name="com.urbanairship.push.RECEIVED" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>

<receiver android:name="com.urbanairship.CoreReceiver" android:exported="false">
<intent-filter android:priority="-999">
<action android:name="com.urbanairship.push.OPENED" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>

<!-- ADM -->
<amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false" />
<receiver android:name="com.urbanairship.push.ADMPushReceiver"
android:permission="com.amazon.device.messaging.permission.SEND">
<intent-filter>
<action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
<action android:name="com.amazon.device.messaging.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>

<!-- GCM -->
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<receiver android:name="com.urbanairship.push.GCMPushReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>

<service android:name="com.urbanairship.location.LocationService" android:label="Segments Service" />
<service android:name="com.urbanairship.push.PushService" android:label="Push Notification Service" />
<service android:name="com.urbanairship.analytics.EventService" android:label="Event Service" />
<service android:name="com.urbanairship.actions.ActionService" />

<provider android:name="com.urbanairship.UrbanAirshipProvider"
android:authorities="${applicationId}.urbanairship.provider"
android:exported="true" android:multiprocess="true"
android:permission="${applicationId}.permission.UA_DATA" />

<!-- End of Urban Airship -->


</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-feature android:name="android.hardware.touchscreen" />
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct"
android:required="false" />
</manifest>
Binary file added android-plugin/aars/urbanairship-lib-5.1.4.aar
Binary file not shown.
11 changes: 11 additions & 0 deletions android-plugin/airshipconfig-template.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
productionAppKey = APP_KEY
productionAppSecret = APP_SECRET
gcmSender = GCM_SENDER


# LogLevel is "VERBOSE", "DEBUG", "INFO", "WARN", "ERROR" or "ASSERT"
developmentLogLevel = DEBUG
productionLogLevel = ERROR
minSdkVersion = 10

inProduction = true
Loading

0 comments on commit fda32f9

Please sign in to comment.