Skip to content

Commit 05efe22

Browse files
committed
Alert notifications, set subscription, send notifications, and fixes
* Moved SDK project from Eclipse to Android Studio. ##### Features * Added option to display an alert dialog when the user is in your app. - Also option to allow showing in the notification area too. * Can now specify a different activity or a broadcast receiver to be opened instead of the launcher activity by defining a com.onesignal.NotificationOpened.RECEIVE action to receive the event. * Added postNotification to make it easier to send notifications from user to user or schedule a future one to the same device. * Added setSubscription method to allow unsubscribing from notifications. * Added error detection for the following: * Invalid OneSignal AppId format or example id being used. * Invalid Google Project number format. * Old revision or missing Android Support Library v4. * Missing Google Play services library. * Now logs returned JSON from OneSignal calls if LOG_LEVEL.INFO is set or higher. ##### Fixes * Fixed crash that could happen when OneSignal.onPaused() is called before OneSignal.init() * Now retries up to 5 times to get a Google Registration id from Google to subscribe for push notifications.
1 parent f910c98 commit 05efe22

File tree

112 files changed

+1819
-209
lines changed

Some content is hidden

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

112 files changed

+1819
-209
lines changed

OneSignalSDK/.classpath

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

OneSignalSDK/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gradle
2+
local.properties
3+
**/.idea/workspace.xml
4+
**/.idea/libraries
5+
.DS_Store
6+
/build
7+
/captures
8+
*.gpg

OneSignalSDK/.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OneSignalSDK/.idea/compiler.xml

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

OneSignalSDK/.idea/copyright/profiles_settings.xml

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

OneSignalSDK/.idea/gradle.xml

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

OneSignalSDK/.idea/misc.xml

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

OneSignalSDK/.idea/modules.xml

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

OneSignalSDK/.idea/vcs.xml

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

OneSignalSDK/.project

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

OneSignalSDK/AndroidManifest.xml

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

OneSignalSDK/OneSignalExampleDev.iml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id="OneSignalExampleDev" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="java-gradle" name="Java-Gradle">
5+
<configuration>
6+
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
7+
<option name="BUILDABLE" value="false" />
8+
</configuration>
9+
</facet>
10+
</component>
11+
<component name="NewModuleRootManager" inherit-compiler-output="true">
12+
<exclude-output />
13+
<content url="file://$MODULE_DIR$">
14+
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
15+
</content>
16+
<orderEntry type="inheritedJdk" />
17+
<orderEntry type="sourceFolder" forTests="false" />
18+
</component>
19+
</module>

OneSignalSDK/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

OneSignalSDK/app/app.iml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="OneSignalExampleDev" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="android-gradle" name="Android-Gradle">
5+
<configuration>
6+
<option name="GRADLE_PROJECT_PATH" value=":app" />
7+
</configuration>
8+
</facet>
9+
<facet type="android" name="Android">
10+
<configuration>
11+
<option name="SELECTED_BUILD_VARIANT" value="debug" />
12+
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
13+
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
14+
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
15+
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
16+
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
17+
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
18+
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
19+
<option name="ALLOW_USER_CONFIGURATION" value="false" />
20+
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
21+
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
22+
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
23+
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
24+
</configuration>
25+
</facet>
26+
</component>
27+
<component name="NewModuleRootManager" inherit-compiler-output="false">
28+
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
29+
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
30+
<exclude-output />
31+
<content url="file://$MODULE_DIR$">
32+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
33+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
34+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
35+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
36+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
37+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
38+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
39+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
40+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
41+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
42+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
43+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
44+
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
45+
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
46+
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
47+
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
48+
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
49+
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
50+
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
51+
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
52+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
53+
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
54+
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
55+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
56+
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
57+
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
58+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
59+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
60+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
61+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
62+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
63+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
64+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
65+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
66+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
67+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
68+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
69+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
70+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
71+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
72+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.1.1/jars" />
73+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.1.1/jars" />
74+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
75+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
76+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
77+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
78+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
79+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
80+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
81+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
82+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
83+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
84+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
85+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
86+
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
87+
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
88+
</content>
89+
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
90+
<orderEntry type="sourceFolder" forTests="false" />
91+
<orderEntry type="library" exported="" name="appcompat-v7-22.1.1" level="project" />
92+
<orderEntry type="library" exported="" name="support-v4-22.1.1" level="project" />
93+
<orderEntry type="library" exported="" name="support-annotations-22.1.1" level="project" />
94+
<orderEntry type="module" module-name="onesignal" exported="" />
95+
</component>
96+
</module>

OneSignalSDK/app/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 22
5+
buildToolsVersion "22.0.1"
6+
7+
defaultConfig {
8+
applicationId "com.onesignal.example"
9+
manifestPlaceholders = [manifestApplicationId:"${applicationId}"]
10+
minSdkVersion 10
11+
targetSdkVersion 22
12+
versionCode 1
13+
versionName "1.0"
14+
}
15+
buildTypes {
16+
release {
17+
minifyEnabled false
18+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19+
}
20+
}
21+
}
22+
23+
dependencies {
24+
compile fileTree(dir: 'libs', include: ['*.jar'])
25+
compile 'com.android.support:appcompat-v7:22.1.1'
26+
//compile 'com.onesignal:OneSignal:1.8.1+@aar'
27+
compile project(':onesignal')
28+
}

OneSignalSDK/proguard-project.txt renamed to OneSignalSDK/app/proguard-rules.pro

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
# To enable ProGuard in your project, edit project.properties
2-
# to define the proguard.config property as described in that file.
3-
#
41
# Add project specific ProGuard rules here.
52
# By default, the flags in this file are appended to flags specified
6-
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7-
# You can edit the include path and order by changing the ProGuard
8-
# include property in project.properties.
3+
# in C:\Program Files (x86)\Android\sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
96
#
107
# For more details, see
118
# http://developer.android.com/guide/developing/tools/proguard.html
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.onesignal.example;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.onesignal.example" >
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:theme="@style/AppTheme" >
10+
<activity
11+
android:name=".MainActivity"
12+
android:label="@string/app_name" >
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
<activity
19+
android:name=".MainActivity2Activity"
20+
android:label="@string/title_activity_main_activity2"
21+
android:exported="false" >
22+
<intent-filter>
23+
<action android:name="com.onesignal.NotificationOpened.RECEIVE" />
24+
<category android:name="android.intent.category.DEFAULT" />
25+
</intent-filter>
26+
</activity>
27+
28+
<receiver
29+
android:name="com.onesignal.example.TestNotificationOpenedReceiver"
30+
android:exported="false">
31+
<intent-filter>
32+
<action android:name="com.onesignal.NotificationOpened.RECEIVE" />
33+
</intent-filter>
34+
</receiver>
35+
</application>
36+
37+
</manifest>

0 commit comments

Comments
 (0)