Skip to content

Commit

Permalink
Merge pull request urbanairship#85 from urbanairship/MB-266
Browse files Browse the repository at this point in the history
MB-266: Update Phonegap for iOS SDK 4.0.0 and Android SDK 4.0.1
  • Loading branch information
rlepinski committed Apr 30, 2014
2 parents 6951de3 + f728e5c commit 09af3a2
Show file tree
Hide file tree
Showing 89 changed files with 2,697 additions and 346 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
==================================
Version 2.4.0 - April 23, 2014
==================================
- Updated for Cordova 3.4.0+
- Updated Urban Airship iOS Library to 4.0.0
- Updated Urban Airship Android Library to 4.0.1,
CHANGELOG: http://docs.urbanairship.com/reference/libraries/android/latest/android_changelog.txt

==================================
Version 2.3.3 - April 18, 2014
==================================
Expand Down
12 changes: 12 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Migration Guide

## 2.3.x to 2.4.0

### Installation changes:

For iOS, make sure you update your iOS project to Cordova iOS version 3.4.1 before installing the phonegap-ua-push plugin.
For example:
```
1. cordova platform update ios
iOS project is now at version 3.4.1
2. phonegap local plugin add https://github.com/urbanairship/phonegap-ua-push.git
```

## 2.2.x to 2.3.0

### Config Changes:
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ This plugin supports PhoneGap/Cordova apps running on both iOS and Android.

### Version Requirements

This plugin is meant to work with PhoneGap 3.0.0+ and the latest version of the Urban Airship library.
This plugin is meant to work with Cordova 3.4.0+ and the latest version of the Urban Airship library.
More documentation and integration guides for IOS and Android are availble on our
[website](https://docs.urbanairship.com/display/DOCS/Client%3A+PhoneGap).

### Older PhoneGap versions

A older version of the plugin for Phonegap 2.6 - 2.9 can be found [here](https://github.com/urbanairship/phonegap-ua-push/tree/1.0.8).
An older unsupported version of the plugin for Phonegap 3.0 can be found [here](https://github.com/urbanairship/phonegap-ua-push/tree/2.3.3)
and for Phonegap 2.6 - 2.9 can be found [here](https://github.com/urbanairship/phonegap-ua-push/tree/1.0.8).

### Contributing Code

Expand All @@ -26,12 +27,15 @@ A migration guide for newer releases of the plugin can be found [here](MIGRATION
## Installation

#### Automatic Installation using PhoneGap/Cordova CLI (iOS and Android)
1. Install this plugin using PhoneGap/Cordova cli:
```
phonegap local plugin add https://github.com/urbanairship/phonegap-ua-push.git
```
1. For iOS, make sure you update your iOS project to Cordova iOS version 3.4.1 before installing this plugin.

2. Modify the www/config.xml directory to contain (replacing with your configuration settings):
cordova platform update ios

2. Install this plugin using PhoneGap/Cordova cli:

phonegap local plugin add https://github.com/urbanairship/phonegap-ua-push.git

3. Modify the www/config.xml directory to contain (replacing with your configuration settings):

<!-- Urban Airship app credentials -->
<preference name="com.urbanairship.production_app_key" value="PRODUCTION_APP_KEY" />
Expand All @@ -49,8 +53,7 @@ phonegap local plugin add https://github.com/urbanairship/phonegap-ua-push.git
<preference name="com.urbanairship.gcm_sender" value="GCM_SENDER_ID" />


3. If your app supports Android API < 14, then you have to manually instrument any Android Activities to
have proper analytics.
4. If your app supports Android API < 14, then you have to manually instrument any Android Activities to have proper analytics.
See [Instrumenting Android Analytics](http://docs.urbanairship.com/build/android_features.html#setting-up-analytics-minor-assembly-required).

#### iOS manual installation (unnecessary if installed automatically)
Expand Down
60 changes: 53 additions & 7 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.urbanairship.phonegap.PushNotification"
version="2.3.3">
version="2.4.0">

<name>Urban Airship Push Notification Plugin</name>

Expand All @@ -11,7 +11,7 @@
<license>Apache 2.0</license>

<engines>
<engine name="cordova" version=">=3.0.0" />
<engine name="cordova" version=">=3.4.0" />
</engines>

<dependency id="org.apache.cordova.device" url="https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git" commit="master" subdir="." />
Expand Down Expand Up @@ -53,12 +53,25 @@
</intent-filter>
</receiver>

<meta-data android:name="com.urbanairship.autopilot" android:value="com.urbanairship.phonegap.PushAutopilot" />

<meta-data android:name="com.urbanairship.autopilot" android:value="com.urbanairship.phonegap.PushAutopilot" />
<activity android:name="com.urbanairship.actions.ActionActivity"/>
<activity
android:name="com.urbanairship.actions.LandingPageActivity"
android:exported="false">

<meta-data android:name="meta" android:value="what" />
<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>

<service android:name="com.urbanairship.push.PushService" android:label="Push Notification Service"/>
<service android:name="com.urbanairship.push.PushWorkerService" android:label="Push Notification Worker 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="$PACKAGE_NAME.urbanairship.provider"
Expand All @@ -71,7 +84,7 @@
<source-file src="src/android/PushNotificationPlugin.java" target-dir="src/com/urbanairship/phonegap" />
<source-file src="src/android/PushReceiver.java" target-dir="src/com/urbanairship/phonegap" />
<source-file src="src/android/PushAutopilot.java" target-dir="src/com/urbanairship/phonegap" />
<source-file src="src/android/urbanairship-lib-3.3.1.jar" target-dir="libs/" />
<source-file src="src/android/urbanairship-lib-4.0.1.jar" target-dir="libs/" />
</platform>

<!-- ios -->
Expand Down Expand Up @@ -118,18 +131,51 @@
<header-file src="src/ios/Airship/Common/UAObservable.h" />
<header-file src="src/ios/Airship/Common/NSJSONSerialization+UAAdditions.h" />
<header-file src="src/ios/Airship/Common/UAURLProtocol.h" />
<header-file src="src/ios/Airship/Common/NSString+URLEncoding.h" />
<header-file src="src/ios/Airship/Common/UAAction+Operators.h" />
<header-file src="src/ios/Airship/Common/UAAction.h" />
<header-file src="src/ios/Airship/Common/UAActionArguments.h" />
<header-file src="src/ios/Airship/Common/UAActionJSDelegate.h" />
<header-file src="src/ios/Airship/Common/UAActionRegistry.h" />
<header-file src="src/ios/Airship/Common/UAActionRegistryEntry.h" />
<header-file src="src/ios/Airship/Common/UAActionResult.h" />
<header-file src="src/ios/Airship/Common/UAActionRunner.h" />
<header-file src="src/ios/Airship/Common/UAAddTagsAction.h" />
<header-file src="src/ios/Airship/Common/UAAggregateActionResult.h" />
<header-file src="src/ios/Airship/Common/UAApplicationMetrics.h" />
<header-file src="src/ios/Airship/Common/UABespokeCloseView.h" />
<header-file src="src/ios/Airship/Common/UABeveledLoadingIndicator.h" />
<header-file src="src/ios/Airship/Common/UACloseWindowAction.h" />
<header-file src="src/ios/Airship/Common/UAIncomingPushAction.h" />
<header-file src="src/ios/Airship/Common/UAIncomingRichPushAction.h" />
<header-file src="src/ios/Airship/Common/UAJavaScriptDelegate.h" />
<header-file src="src/ios/Airship/Common/UALandingPageOverlayController.h" />
<header-file src="src/ios/Airship/Common/UAModifyTagsAction.h" />
<header-file src="src/ios/Airship/Common/UAOpenExternalURLAction.h" />
<header-file src="src/ios/Airship/Common/UAPushActionArguments.h" />
<header-file src="src/ios/Airship/Common/UARemoveTagsAction.h" />
<header-file src="src/ios/Airship/Common/UARichContentWindow.h" />
<header-file src="src/ios/Airship/Common/UASyncAction.h" />
<header-file src="src/ios/Airship/Common/UAWebInvocationActionArguments.h" />
<header-file src="src/ios/Airship/Common/UAWebViewCallData.h" />
<header-file src="src/ios/Airship/Common/UAWebViewTools.h" />
<header-file src="src/ios/Airship/Common/UIWebView+UAAdditions.h" />
<header-file src="src/ios/Airship/Common/JS/UANativeBridge.h" />
<header-file src="src/ios/Airship/Common/LandingPages/UALandingPageAction.h" />

<!-- Push header files -->
<header-file src="src/ios/Airship/Push/UADeviceAPIClient.h" />
<header-file src="src/ios/Airship/Push/UADeviceRegistrationData.h" />
<header-file src="src/ios/Airship/Push/UADeviceRegistrationPayload.h" />
<header-file src="src/ios/Airship/Push/UAPush.h" />
<header-file src="src/ios/Airship/Push/UAChannelAPIClient.h" />
<header-file src="src/ios/Airship/Push/UAChannelRegistrationPayload.h" />
<header-file src="src/ios/Airship/Push/UADeviceRegistrar.h" />

<!-- External header files -->
<header-file src="src/ios/Airship/External/UA_Base64.h" />
<header-file src="src/ios/Airship/External/UA_Reachability.h" />

<source-file src="src/ios/Airship/libUAirship-iOS5-3.0.3.a" framework="true"/>
<source-file src="src/ios/Airship/libUAirship-4.0.0.a" framework="true"/>

<!-- system frameworks -->
<framework src="libsqlite3.dylib" />
Expand Down
24 changes: 19 additions & 5 deletions src/android/PushReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@
import com.urbanairship.Logger;
import com.urbanairship.UAirship;
import com.urbanairship.push.PushManager;
import com.urbanairship.actions.ActionUtils;
import com.urbanairship.actions.DeepLinkAction;
import com.urbanairship.actions.LandingPageAction;
import com.urbanairship.actions.OpenExternalUrlAction;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PushReceiver extends BroadcastReceiver {
// A set of actions that launch activities when a push is opened. Update
// with any custom actions that also start activities when a push is opened.
private static String[] ACTIVITY_ACTIONS = new String[] {
DeepLinkAction.DEFAULT_REGISTRY_NAME,
OpenExternalUrlAction.DEFAULT_REGISTRY_NAME,
LandingPageAction.DEFAULT_REGISTRY_NAME
};

private static final List<String> IGNORED_EXTRAS_KEYS = Arrays.asList(
"collapse_key",// c2dm collapse key
Expand Down Expand Up @@ -54,14 +65,17 @@ private void handleNotificationOpened(Context context, Intent intent) {
Logger.info("User clicked notification. Message: " + alert
+ ". Payload: " + extras.toString());

Intent launch = context.getPackageManager().getLaunchIntentForPackage(UAirship.getPackageName());
launch.addCategory(Intent.CATEGORY_LAUNCHER);
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PushNotificationPlugin.incomingAlert = alert;
PushNotificationPlugin.incomingExtras = extras;

context.startActivity(launch);
// Only launch the main activity if the payload does not contain any
// actions that might have already opened an activity
if (!ActionUtils.containsRegisteredActions(intent.getExtras(), ACTIVITY_ACTIONS)) {
Intent launch = context.getPackageManager().getLaunchIntentForPackage(UAirship.getPackageName());
launch.addCategory(Intent.CATEGORY_LAUNCHER);
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(launch);
}
}

private void handleRegistrationFinished(Intent intent) {
Expand Down
Binary file removed src/android/urbanairship-lib-3.3.1.jar
Binary file not shown.
Binary file added src/android/urbanairship-lib-4.0.1.jar
Binary file not shown.
11 changes: 11 additions & 0 deletions src/ios/Airship/Common/JS/UANativeBridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* A static C string representing the contents of UANativeBridge.js.
*
* @note This array is autogenerated with a pre-build script.
*/
extern unsigned char UANativeBridge_js[];

/**
* The length of the UANativeBridge_js array, in bytes.
*/
extern unsigned int UANativeBridge_js_len;
47 changes: 47 additions & 0 deletions src/ios/Airship/Common/LandingPages/UALandingPageAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2009-2014 Urban Airship Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binaryform must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided withthe distribution.
THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "UAAction.h"

/**
* Opens a landing page URL in a rich content window.
*
* This action is registered under the names landing_page_action and ^p.
*
* Expected argument values: NSString or NSURL. Short url formats are in the form
* of "u:<content-id>" and will be used to construct a new URL using the content-id.
*
* Valid situations: UASituationForegroundPush, UASituationLanchedFromPush,
* UASituationWebViewInvocation, UASituationManualInvocation.
*
* In the background situation, this action will attempt to pre-fetch the data and cache it for later use.
*
* Result value: nil
*
* Fetch result: UAActionFetchResultNewData, or UAActionFetchResultFailed if the data could not be fetched.
*
*/
@interface UALandingPageAction : UAAction
@end
68 changes: 67 additions & 1 deletion src/ios/Airship/Common/NSJSONSerialization+UAAdditions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2009-2013 Urban Airship Inc. All rights reserved.
Copyright 2009-2014 Urban Airship Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand All @@ -25,6 +25,15 @@

#import <Foundation/Foundation.h>

/**
* The domain for NSErrors generated by the NSJSONSerialization+UAAdditions methods.
*/
extern NSString * const UAJSONSerializationErrorDomain;

NS_ENUM(NSInteger, UAJSONSerializationErrorCode) {
UAJSONSerializationErrorCodeInvalidObject
};

/**
* The NSJSONSerialization convenience methods.
*/
Expand All @@ -34,9 +43,38 @@
* Converts a Foundation object to a JSON formatted NSString
* @param jsonObject Foundation object to convert
* @return NSString formatted as JSON, or nil if an error occurs
* @note Writing JSON strings with this method defaults to no NSJSONWritingOptions, and does not accept fragments.
*/
+ (NSString *)stringWithObject:(id)jsonObject;

/**
* Converts a Foundation object to a JSON formatted NSString
* @param jsonObject Foundation object to convert
* @param error An NSError pointer for storing errors, if applicable.
* @return NSString formatted as JSON, or nil if an error occurs
* @note Writing JSON strings with this method defaults to no NSJSONWritingOptions, and does not accept fragments.
*/
+ (NSString *)stringWithObject:(id)jsonObject error:(NSError **)error;

/**
* Converts a Foundation object to a JSON formatted NSString
* @param jsonObject Foundation object to convert
* @param acceptingFragments `YES` if objects representing JSON value fragments are acceptable, `NO` otherwise.
* @return NSString formatted as JSON, or nil if an error occurs.
* @note Writing JSON strings with this method defaults to no NSJSONWritingOptions.
*/
+ (NSString *)stringWithObject:(id)jsonObject acceptingFragments:(BOOL)acceptingFragments;

/**
* Converts a Foundation object to a JSON formatted NSString
* @param jsonObject Foundation object to convert
* @param acceptingFragments `YES` if objects representing JSON value fragments are acceptable, `NO` otherwise.
* @param error An NSError pointer for storing errors, if applicable.
* @return NSString formatted as JSON, or nil if an error occurs.
* @note Writing JSON strings with this method defaults to no NSJSONWritingOptions.
*/
+ (NSString *)stringWithObject:(id)jsonObject acceptingFragments:(BOOL)acceptingFragments error:(NSError **)error;

/**
* Converts a Foundation object to a JSON formatted NSString
* @param jsonObject Foundation object to convert
Expand All @@ -45,11 +83,39 @@
*/
+ (NSString *)stringWithObject:(id)jsonObject options:(NSJSONWritingOptions)opt;

/**
* Converts a Foundation object to a JSON formatted NSString
* @param jsonObject Foundation object to convert
* @param opt NSJSONWritingOptions options
* @param error An NSError pointer for storing errors, if applicable.
* @return NSString formatted as JSON, or nil if an error occurs
*/
+ (NSString *)stringWithObject:(id)jsonObject options:(NSJSONWritingOptions)opt error:(NSError **)error;


/**
* Create a Foundation object from JSON string
* @param jsonString the JSON NSString to convert
* @return A Foundation object, or nil if an error occurs.
* @note Creating objects with this method defaults to NSJSONReadingMutableContainers options.
*/
+ (id)objectWithString:(NSString *)jsonString;

/**
* Create a Foundation object from JSON string
* @param jsonString the JSON NSString to convert
* @param opt NSJSONReadingOptions
* @return A Foundation object, or nil if an error occurs.
*/
+ (id)objectWithString:(NSString *)jsonString options:(NSJSONReadingOptions)opt;

/**
* Create a Foundation object from JSON string
* @param jsonString the JSON NSString to convert
* @param opt NSJSONReadingOptions
* @param error An NSError pointer for storing errors, if applicable.
* @return A Foundation object, or nil if an error occurs.
*/
+ (id)objectWithString:(NSString *)jsonString options:(NSJSONReadingOptions)opt error:(NSError **)error;

@end
Loading

0 comments on commit 09af3a2

Please sign in to comment.