Skip to content

Commit 3f3ef10

Browse files
authored
Merge pull request #83 from OneSignal/3.0
🎉 3.0 Release! 🎉
2 parents 0a95913 + d222b5f commit 3f3ef10

File tree

62 files changed

+1402
-817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1402
-817
lines changed

OneSignalSDK.jar

11.2 KB
Binary file not shown.

OneSignalSDK/app/app.iml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@
6464
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
6565
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
6666
<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" />
7567
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
7668
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
7769
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@@ -80,19 +72,27 @@
8072
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
8173
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
8274
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
75+
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
76+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
77+
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
78+
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
79+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
80+
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
81+
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
82+
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
8383
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
8484
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8585
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
8686
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
8787
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
8888
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
8989
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
90-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/9.2.0/jars" />
91-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/9.2.0/jars" />
92-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/9.2.0/jars" />
93-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-iid/9.2.0/jars" />
94-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/9.2.0/jars" />
95-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-tasks/9.2.0/jars" />
90+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/9.2.1/jars" />
91+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/9.2.1/jars" />
92+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/9.2.1/jars" />
93+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-iid/9.2.1/jars" />
94+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/9.2.1/jars" />
95+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-tasks/9.2.1/jars" />
9696
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
9797
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
9898
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
@@ -105,12 +105,13 @@
105105
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/sourceFolderJavaResources" />
106106
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
107107
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
108+
<excludeFolder url="file://$MODULE_DIR$/build/ivy.xml" />
108109
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
109110
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
110111
</content>
111112
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
112113
<orderEntry type="sourceFolder" forTests="false" />
113-
<orderEntry type="library" exported="" name="play-services-base-9.2.0" level="project" />
114+
<orderEntry type="library" exported="" name="play-services-base-9.2.1" level="project" />
114115
<orderEntry type="library" exported="" scope="TEST" name="asm-5.0.1" level="project" />
115116
<orderEntry type="library" exported="" scope="TEST" name="robolectric-utils-3.0" level="project" />
116117
<orderEntry type="library" exported="" scope="TEST" name="ant-1.8.0" level="project" />
@@ -123,22 +124,22 @@
123124
<orderEntry type="library" exported="" scope="TEST" name="robolectric-annotations-3.0" level="project" />
124125
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
125126
<orderEntry type="library" exported="" scope="TEST" name="shadows-core-3.0" level="project" />
127+
<orderEntry type="library" exported="" name="play-services-location-9.2.1" level="project" />
126128
<orderEntry type="library" exported="" scope="TEST" name="asm-commons-5.0.1" level="project" />
127129
<orderEntry type="library" exported="" scope="TEST" name="vtd-xml-2.11" level="project" />
128-
<orderEntry type="library" exported="" name="play-services-location-9.2.0" level="project" />
129130
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
130131
<orderEntry type="library" exported="" scope="TEST" name="asm-tree-5.0.1" level="project" />
131132
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
132133
<orderEntry type="library" exported="" scope="TEST" name="asm-analysis-5.0.1" level="project" />
134+
<orderEntry type="library" exported="" name="play-services-basement-9.2.1" level="project" />
133135
<orderEntry type="library" exported="" scope="TEST" name="icu4j-53.1" level="project" />
134136
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
135-
<orderEntry type="library" exported="" name="play-services-iid-9.2.0" level="project" />
137+
<orderEntry type="library" exported="" name="play-services-iid-9.2.1" level="project" />
136138
<orderEntry type="library" exported="" scope="TEST" name="ant-launcher-1.8.0" level="project" />
137139
<orderEntry type="library" exported="" scope="TEST" name="robolectric-3.0" level="project" />
138-
<orderEntry type="library" exported="" name="play-services-gcm-9.2.0" level="project" />
140+
<orderEntry type="library" exported="" name="play-services-gcm-9.2.1" level="project" />
139141
<orderEntry type="library" exported="" scope="TEST" name="asm-util-5.0.1" level="project" />
140-
<orderEntry type="library" exported="" name="play-services-basement-9.2.0" level="project" />
141-
<orderEntry type="library" exported="" name="play-services-tasks-9.2.0" level="project" />
142+
<orderEntry type="library" exported="" name="play-services-tasks-9.2.1" level="project" />
142143
<orderEntry type="module" module-name="onesignal" exported="" />
143144
</component>
144145
</module>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Modified MIT License
3+
*
4+
* Copyright 2016 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
package com.onesignal.example;
29+
30+
import java.lang.reflect.Field;
31+
32+
public class DebuggingHelper {
33+
34+
static void printObject(Object obj) {
35+
for (Field field : obj.getClass().getDeclaredFields()) {
36+
String name = field.getName();
37+
try {
38+
Object value = field.get(obj);
39+
System.out.printf("Field name: %s, Field value: %s%n", name, value);
40+
} catch (Throwable t){}
41+
}
42+
}
43+
}

OneSignalSDK/app/src/main/java/com/onesignal/example/MainActivity.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
import com.onesignal.*;
4141
import com.onesignal.OneSignal.NotificationOpenedHandler;
4242

43-
import org.json.JSONObject;
44-
4543
import com.onesignal.example.iap.IabHelper;
4644
import com.onesignal.example.iap.IabResult;
4745

@@ -58,22 +56,28 @@ public class MainActivity extends ActionBarActivity {
5856
protected void onCreate(Bundle savedInstanceState) {
5957
super.onCreate(savedInstanceState);
6058
setContentView(R.layout.activity_main);
59+
//
60+
// WebView myWebView = (WebView) findViewById(R.id.webview);
61+
// WebSettings webSettings = myWebView.getSettings();
62+
// webSettings.setJavaScriptEnabled(true);
63+
// WebView.setWebContentsDebuggingEnabled(true);
64+
// myWebView.loadUrl("http://akhbar4all.com");
6165

6266
Log.e("tet", Locale.getDefault().getLanguage());
6367

6468
currentActivity = this;
6569

6670
// OneSignal.setLogLevel(OneSignal.LOG_LEVEL.DEBUG, OneSignal.LOG_LEVEL.NONE);
6771
// OneSignal.startInit(this)
68-
// .setAutoPromptLocation(true)
72+
// .autoPromptLocation(true)
6973
// .setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
7074
// .init();
7175

72-
OneSignal.enableInAppAlertNotification(true);
73-
OneSignal.enableNotificationsWhenActive(false);
74-
OneSignal.sendTag("test3", "test3");
76+
OneSignal.setInFocusDisplaying(OneSignal.OSInFocusDisplayOption.InAppAlert);
77+
OneSignal.sendTag("test3", "test7");
7578
//OneSignal.setSubscription(false);
7679

80+
OneSignal.syncHashedEmail("test@onesignal.com");
7781

7882
// OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() {
7983
// @Override
@@ -158,14 +162,12 @@ private class ExampleNotificationOpenedHandler implements NotificationOpenedHand
158162
* a new one comes in while the app is running.
159163
* This method is located in this activity as an example, you may have any class you wish implement NotificationOpenedHandler and define this method.
160164
*
161-
* @param message The message string the user seen/should see in the Android status bar.
162-
* @param additionalData The additionalData key value pair section you entered in on onesignal.com.
163-
* @param isActive Was the app in the foreground when the notification was received.
165+
* @param openedResult The message string the user seen/should see in the Android status bar.
164166
*/
165167
@Override
166-
public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
167-
Log.e("OneSignalExample", "message: " + message);
168-
Log.e("OneSignalExample", "additional data: " + additionalData);
168+
public void notificationOpened(OSNotificationOpenResult openedResult) {
169+
Log.e("OneSignalExample", "body: " + openedResult.notification.payload.body);
170+
Log.e("OneSignalExample", "additional data: " + openedResult.notification.payload.additionalData);
169171
//Log.e("OneSignalExample", "additionalData: " + additionalData.toString());
170172
}
171173
}

OneSignalSDK/app/src/main/java/com/onesignal/example/NotificationExtenderServiceTest.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44

55
import com.onesignal.OSNotificationPayload;
66
import com.onesignal.NotificationExtenderService;
7+
import com.onesignal.OSNotificationReceivedResult;
78

89
import java.lang.reflect.Field;
910
import java.math.BigInteger;
1011

1112
public class NotificationExtenderServiceTest extends NotificationExtenderService {
1213

1314
@Override
14-
protected boolean onNotificationProcessing(OSNotificationPayload notification) {
15-
printObject(notification);
16-
if (notification.actionButtons != null) {
17-
for(OSNotificationPayload.ActionButton button : notification.actionButtons) {
15+
protected boolean onNotificationProcessing(OSNotificationReceivedResult notification) {
16+
DebuggingHelper.printObject(notification);
17+
if (notification.payload.actionButtons != null) {
18+
for(OSNotificationPayload.ActionButton button : notification.payload.actionButtons) {
1819
// System.out.println("button:");
19-
printObject(button);
20+
DebuggingHelper.printObject(button);
2021
}
2122
}
2223

@@ -33,14 +34,4 @@ public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
3334

3435
return true;
3536
}
36-
37-
private void printObject(Object obj) {
38-
for (Field field : obj.getClass().getDeclaredFields()) {
39-
String name = field.getName();
40-
try {
41-
Object value = field.get(obj);
42-
// System.out.printf("Field name: %s, Field value: %s%n", name, value);
43-
} catch (Throwable t){}
44-
}
45-
}
4637
}
Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
1+
/**
2+
* Modified MIT License
3+
*
4+
* Copyright 2016 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
128
package com.onesignal.example;
229

330
import android.app.Application;
431
import android.os.StrictMode;
532
import android.util.Log;
633

34+
import com.onesignal.OSNotification;
35+
import com.onesignal.OSNotificationOpenResult;
736
import com.onesignal.OneSignal;
837

9-
import org.json.JSONObject;
10-
1138
public class OneSignalExampleApp extends Application {
1239

1340
@Override
@@ -19,26 +46,41 @@ public void onCreate() {
1946

2047
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE);
2148
OneSignal.startInit(this)
22-
.setAutoPromptLocation(true)
49+
.autoPromptLocation(true)
2350
.setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
51+
.setNotificationReceivedHandler(new ExampleNotificationReceivedHandler())
2452
.init();
2553
}
2654

55+
private class ExampleNotificationReceivedHandler implements OneSignal.NotificationReceivedHandler {
56+
/**
57+
* Callback to implement in your app to handle when a notification is received while your app running
58+
* in the foreground or background.
59+
*
60+
* Use a NotificationExtenderService instead to receive an event even when your app is closed (not 'forced stopped')
61+
* or to override notification properties.
62+
*
63+
* @param notification Contains information about the notification received.
64+
*/
65+
@Override
66+
public void notificationReceived(OSNotification notification) {
67+
Log.w("OneSignalExample", "notificationReceived!!!!!!");
68+
DebuggingHelper.printObject(notification);
69+
DebuggingHelper.printObject(notification.payload);
70+
}
71+
}
72+
2773
private class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
2874
/**
29-
* Callback to implement in your app to handle when a notification is opened from the Android status bar or
30-
* a new one comes in while the app is running.
31-
* This method is located in this activity as an example, you may have any class you wish implement NotificationOpenedHandler and define this method.
75+
* Callback to implement in your app to handle when a notification is opened from the Android status bar or in app alert
3276
*
33-
* @param message The message string the user seen/should see in the Android status bar.
34-
* @param additionalData The additionalData key value pair section you entered in on onesignal.com.
35-
* @param isActive Was the app in the foreground when the notification was received.
77+
* @param openedResult Contains information about the notification opened and the action taken on it.
3678
*/
3779
@Override
38-
public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
39-
Log.e("OneSignalExample", "message: " + message);
40-
Log.e("OneSignalExample", "additional data: " + additionalData);
41-
//Log.e("OneSignalExample", "additionalData: " + additionalData.toString());
80+
public void notificationOpened(OSNotificationOpenResult openedResult) {
81+
Log.w("OneSignalExample", "notificationOpened!!!!!!");
82+
DebuggingHelper.printObject(openedResult.action);
83+
DebuggingHelper.printObject(openedResult.notification);
4284
}
4385
}
4486
}

OneSignalSDK/app/src/main/res/layout/activity_main.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@
3131
android:onClick="onUnsubscribeClicked"
3232
android:nestedScrollingEnabled="true"/>
3333

34+
<!--<WebView xmlns:android="http://schemas.android.com/apk/res/android"-->
35+
<!--android:id="@+id/webview"-->
36+
<!--android:layout_width="fill_parent"-->
37+
<!--android:layout_height="fill_parent"-->
38+
<!--/>-->
39+
3440
</RelativeLayout>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<color name="onesignal_notif_bg_image_title_color">#FFFF0000</color>
4-
<color name="onesignal_notif_bg_image_body_color">#FF00FF00</color>
3+
<color name="onesignal_bgimage_notif_title_color">#FFFF0000</color>
4+
<color name="onesignal_bgimage_notif_body_color">#FF00FF00</color>
55
</resources>

0 commit comments

Comments
 (0)