Skip to content

Commit 366115e

Browse files
committed
OSNotification* classes, new method signatures, and syncHashedEmail
* Removing deprecated methods, adding new OSNotification*, re-factoring method names and properties. * syncHashedEmail - optional method that sends us the user's email as an anonymized hash so that we can better target and personalize notifications sent to that user across their devices.
1 parent 0a95913 commit 366115e

23 files changed

+543
-480
lines changed

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>

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.OSDefaultDisplay.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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
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+
protected boolean onNotificationProcessing(OSNotificationReceivedResult notification) {
1516
printObject(notification);
16-
if (notification.actionButtons != null) {
17-
for(OSNotificationPayload.ActionButton button : notification.actionButtons) {
17+
if (notification.payload.actionButtons != null) {
18+
for(OSNotificationPayload.ActionButton button : notification.payload.actionButtons) {
1819
// System.out.println("button:");
1920
printObject(button);
2021
}

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import android.os.StrictMode;
55
import android.util.Log;
66

7+
import com.onesignal.OSNotification;
8+
import com.onesignal.OSNotificationOpenResult;
79
import com.onesignal.OneSignal;
810

9-
import org.json.JSONObject;
10-
1111
public class OneSignalExampleApp extends Application {
1212

1313
@Override
@@ -19,7 +19,7 @@ public void onCreate() {
1919

2020
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE);
2121
OneSignal.startInit(this)
22-
.setAutoPromptLocation(true)
22+
// .autoPromptLocation(true)
2323
.setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
2424
.init();
2525
}
@@ -30,14 +30,12 @@ private class ExampleNotificationOpenedHandler implements OneSignal.Notification
3030
* a new one comes in while the app is running.
3131
* This method is located in this activity as an example, you may have any class you wish implement NotificationOpenedHandler and define this method.
3232
*
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.
33+
* @param openedResult The message string the user seen/should see in the Android status bar.
3634
*/
3735
@Override
38-
public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
39-
Log.e("OneSignalExample", "message: " + message);
40-
Log.e("OneSignalExample", "additional data: " + additionalData);
36+
public void notificationOpened(OSNotificationOpenResult openedResult) {
37+
Log.e("OneSignalExample", "body: " + openedResult.notification.payload.body);
38+
Log.e("OneSignalExample", "additional data: " + openedResult.notification.payload.additionalData);
4139
//Log.e("OneSignalExample", "additionalData: " + additionalData.toString());
4240
}
4341
}

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>

OneSignalSDK/app/src/test/java/com/onesignal/OneSignalPackagePrivateHelper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ public static void NotificationBundleProcessor_ProcessFromGCMIntentService_NoWra
6060
}
6161

6262
public static boolean GcmBroadcastReceiver_processBundle(Context context, Bundle bundle) {
63-
return GcmBroadcastReceiver.processBundle(context, bundle);
63+
return NotificationBundleProcessor.processBundle(context, bundle);
64+
}
65+
66+
public static void OneSignalStateSynchronizer_syncUserState(boolean fromSyncService) {
67+
OneSignalStateSynchronizer.syncUserState(fromSyncService);
6468
}
6569

6670

0 commit comments

Comments
 (0)