Skip to content

Commit f200921

Browse files
committed
Updated examples for 3.0 release.
1 parent 9467856 commit f200921

File tree

15 files changed

+233
-302
lines changed

15 files changed

+233
-302
lines changed

Examples/AndroidStudio/.idea/gradle.xml

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/AndroidStudio/.idea/misc.xml

Lines changed: 56 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/AndroidStudio/.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

Examples/AndroidStudio/app/app.iml

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
1313
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
1414
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
15-
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
16-
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
1715
<afterSyncTasks>
18-
<task>generateDebugAndroidTestSources</task>
1916
<task>generateDebugSources</task>
2017
</afterSyncTasks>
2118
<option name="ALLOW_USER_CONFIGURATION" value="false" />
@@ -28,7 +25,7 @@
2825
</component>
2926
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
3027
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
31-
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
28+
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
3229
<exclude-output />
3330
<content url="file://$MODULE_DIR$">
3431
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
@@ -50,57 +47,82 @@
5047
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
5148
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
5249
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
50+
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
51+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
52+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
53+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
54+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
55+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
56+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
57+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
58+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
5359
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
5460
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
5561
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
5662
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
5763
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
5864
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
5965
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
66+
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
67+
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
68+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
69+
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
70+
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
71+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
72+
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
73+
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
74+
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
6075
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
6176
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
6277
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
6378
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
6479
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
6580
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
6681
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
82+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
6783
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
6884
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
85+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
6986
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
7087
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
71-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
72-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
73-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/8.3.0/jars" />
74-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.3.0/jars" />
75-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.3.0/jars" />
76-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/8.3.0/jars" />
77-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.3.0/jars" />
78-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/8.3.0/jars" />
79-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-measurement/8.3.0/jars" />
80-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.onesignal/OneSignal/2.0.0/jars" />
88+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/24.1.1/jars" />
89+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.1.1/jars" />
90+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/24.1.1/jars" />
91+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.1.1/jars" />
92+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/9.4.0/jars" />
93+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/9.4.0/jars" />
94+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/9.4.0/jars" />
95+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-iid/9.4.0/jars" />
96+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/9.4.0/jars" />
97+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-tasks/9.4.0/jars" />
98+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.onesignal/OneSignal/3.0.0/jars" />
8199
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
100+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
101+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
82102
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
83103
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
84104
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
85105
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
86106
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
107+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
87108
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
88109
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
89110
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
90111
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
91112
</content>
92113
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
93114
<orderEntry type="sourceFolder" forTests="false" />
94-
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
95-
<orderEntry type="library" exported="" name="play-services-location-8.3.0" level="project" />
96-
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
97-
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
98-
<orderEntry type="library" exported="" name="play-services-base-8.3.0" level="project" />
99-
<orderEntry type="library" exported="" name="OneSignal-2.0.0" level="project" />
100-
<orderEntry type="library" exported="" name="play-services-gcm-8.3.0" level="project" />
101-
<orderEntry type="library" exported="" name="play-services-analytics-8.3.0" level="project" />
102-
<orderEntry type="library" exported="" name="play-services-maps-8.3.0" level="project" />
103-
<orderEntry type="library" exported="" name="play-services-measurement-8.3.0" level="project" />
104-
<orderEntry type="library" exported="" name="play-services-basement-8.3.0" level="project" />
115+
<orderEntry type="library" exported="" name="play-services-gcm-9.4.0" level="project" />
116+
<orderEntry type="library" exported="" name="play-services-location-9.4.0" level="project" />
117+
<orderEntry type="library" exported="" name="play-services-basement-9.4.0" level="project" />
118+
<orderEntry type="library" exported="" name="animated-vector-drawable-24.1.1" level="project" />
119+
<orderEntry type="library" exported="" name="support-vector-drawable-24.1.1" level="project" />
120+
<orderEntry type="library" exported="" name="support-v4-24.1.1" level="project" />
121+
<orderEntry type="library" exported="" name="appcompat-v7-24.1.1" level="project" />
122+
<orderEntry type="library" exported="" name="play-services-base-9.4.0" level="project" />
123+
<orderEntry type="library" exported="" name="play-services-iid-9.4.0" level="project" />
124+
<orderEntry type="library" exported="" name="play-services-tasks-9.4.0" level="project" />
125+
<orderEntry type="library" exported="" name="support-annotations-24.1.1" level="project" />
126+
<orderEntry type="library" exported="" name="OneSignal-3.0.0" level="project" />
105127
</component>
106128
</module>

Examples/AndroidStudio/app/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 23
5-
buildToolsVersion "23.0.2"
5+
buildToolsVersion "23.0.3"
66

77
defaultConfig {
88
applicationId "com.onesignal.example"
@@ -31,10 +31,15 @@ dependencies {
3131
compile 'com.android.support:appcompat-v7:+'
3232

3333
// OneSignal SDK
34-
compile 'com.onesignal:OneSignal:2.+@aar'
34+
compile 'com.onesignal:OneSignal:3.+@aar'
3535

3636
// OneSignal requires at least version 7.0.0 of GMS but the newest version is recommend.
37+
// Required for OneSignal, even if you have added FCM.
3738
compile 'com.google.android.gms:play-services-gcm:+'
38-
compile 'com.google.android.gms:play-services-analytics:+'
39+
40+
// Required for geotagging
3941
compile 'com.google.android.gms:play-services-location:+'
42+
43+
// play-services-analytics is only needed when using 8.1.0 or older.
44+
// compile 'com.google.android.gms:play-services-analytics:+'
4045
}

Examples/AndroidStudio/app/src/main/java/com/onesignal/example/ExampleApplication.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.app.Application;
44
import android.util.Log;
55

6+
import com.onesignal.OSNotificationAction;
7+
import com.onesignal.OSNotificationOpenResult;
68
import com.onesignal.OneSignal;
79

810
import org.json.JSONObject;
@@ -18,37 +20,36 @@ public void onCreate() {
1820

1921
OneSignal.startInit(this)
2022
.setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
21-
.setAutoPromptLocation(true)
23+
.autoPromptLocation(true)
2224
.init();
2325
}
2426

2527

2628
private class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
27-
/**
28-
* Callback to implement in your app to handle when a notification is opened from the Android status bar or
29-
* a new one comes in while the app is running.
30-
* This method is located in this Application class as an example, you may have any class you wish implement NotificationOpenedHandler and define this method.
31-
*
32-
* @param message The message string the user seen/should see in the Android status bar.
33-
* @param additionalData The additionalData key value pair section you entered in on onesignal.com.
34-
* @param isActive Was the app in the foreground when the notification was received.
35-
*/
29+
// This fires when a notification is opened by tapping on it.
3630
@Override
37-
public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
38-
String additionalMessage = "";
31+
public void notificationOpened(OSNotificationOpenResult result) {
32+
OSNotificationAction.ActionType actionType = result.action.actionType;
33+
JSONObject data = result.notification.payload.additionalData;
34+
String customKey;
35+
36+
if (data != null) {
37+
customKey = data.optString("customkey", null);
38+
if (customKey != null)
39+
Log.i("OneSignalExample", "customkey set with value: " + customKey);
40+
}
3941

40-
try {
41-
if (additionalData != null) {
42-
if (additionalData.has("actionSelected"))
43-
additionalMessage += "Pressed ButtonID: " + additionalData.getString("actionSelected");
42+
if (actionType == OSNotificationAction.ActionType.ActionTaken)
43+
Log.i("OneSignalExample", "Button pressed with id: " + result.action.actionID);
4444

45-
additionalMessage = message + "\nFull additionalData:\n" + additionalData.toString();
46-
}
45+
// The following can be used to open an Activity of your choice.
4746

48-
Log.d("OneSignalExample", "message:\n" + message + "\nadditionalMessage:\n" + additionalMessage);
49-
} catch (Throwable t) {
50-
t.printStackTrace();
51-
}
47+
// Intent intent = new Intent(getApplication(), YourActivity.class);
48+
// intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
49+
// startActivity(intent);
50+
51+
// Follow the instructions in the link below to prevent the launcher Activity from starting.
52+
// https://documentation.onesignal.com/docs/android-notification-customizations#changing-the-open-action-of-a-notification
5253
}
5354
}
5455
}

Examples/AndroidStudio/app/src/test/java/com/onesignal/example/ExampleUnitTest.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

Examples/AndroidStudio/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:1.5.0'
8+
classpath 'com.android.tools.build:gradle:2.1.2'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Oct 29 13:34:39 PDT 2015
1+
#Mon Aug 08 19:09:22 PDT 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

0 commit comments

Comments
 (0)