Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Examples/OneSignalDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'

implementation 'com.google.android.material:material:1.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,40 @@ public static void sendDeviceNotification(final Notification notification) {
"'android_accent_color': 'FFE9444E'," +
"'android_sound': 'nil'}");

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
HttpURLConnection con = (HttpURLConnection) new URL("https://onesignal.com/api/v1/notifications").openConnection();
HttpURLConnection con = (HttpURLConnection) new URL("https://onesignal.com/api/v1/notifications").openConnection();

con.setUseCaches(false);
con.setConnectTimeout(30000);
con.setReadTimeout(30000);
con.setRequestProperty("Accept", "application/vnd.onesignal.v1+json");
con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
con.setConnectTimeout(30000);
con.setReadTimeout(30000);
con.setRequestProperty("Accept", "application/vnd.onesignal.v1+json");
con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);

byte[] outputBytes = notificationContent.toString().getBytes(StandardCharsets.UTF_8);
con.setFixedLengthStreamingMode(outputBytes.length);
con.getOutputStream().write(outputBytes);
byte[] outputBytes = notificationContent.toString().getBytes(StandardCharsets.UTF_8);
con.setFixedLengthStreamingMode(outputBytes.length);
con.getOutputStream().write(outputBytes);

int httpResponse = con.getResponseCode();
int httpResponse = con.getResponseCode();

if(httpResponse == HttpURLConnection.HTTP_ACCEPTED || httpResponse == HttpURLConnection.HTTP_OK) {
InputStream inputStream = con.getInputStream();
Scanner scanner = new Scanner(inputStream, "UTF-8");
String responseStr = "";
if (scanner.useDelimiter("\\A").hasNext())
responseStr = scanner.next();
scanner.close();
Log.d(Tag.LOG_TAG, "Success sending notification: " + responseStr);
}
else {
InputStream inputStream = con.getErrorStream();
Scanner scanner = new Scanner(inputStream, "UTF-8");
String responseStr = "";
if (scanner.useDelimiter("\\A").hasNext())
responseStr = scanner.next();
scanner.close();
Log.d(Tag.LOG_TAG, "Failure sending notification: " + responseStr);
}
if(httpResponse == HttpURLConnection.HTTP_ACCEPTED || httpResponse == HttpURLConnection.HTTP_OK) {
InputStream inputStream = con.getInputStream();
Scanner scanner = new Scanner(inputStream, "UTF-8");
String responseStr = "";
if (scanner.useDelimiter("\\A").hasNext())
responseStr = scanner.next();
scanner.close();
Log.d(Tag.LOG_TAG, "Success sending notification: " + responseStr);
}
else {
InputStream inputStream = con.getErrorStream();
Scanner scanner = new Scanner(inputStream, "UTF-8");
String responseStr = "";
if (scanner.useDelimiter("\\A").hasNext())
responseStr = scanner.next();
scanner.close();
Log.d(Tag.LOG_TAG, "Failure sending notification: " + responseStr);
}
} catch (Exception e) {
e.printStackTrace();
Expand Down
6 changes: 0 additions & 6 deletions OneSignalSDK/onesignal/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ dependencies {

compileOnly('com.amazon.device:amazon-appstore-sdk:[3.0.1, 3.0.99]')

api('androidx.legacy:legacy-support-v4') {
version {
require '[1.0.0, 1.0.99]'
prefer '1.0.0'
}
}
api('androidx.appcompat:appcompat') {
version {
require '[1.0.0, 1.3.99]'
Expand Down
5 changes: 0 additions & 5 deletions OneSignalSDK/onesignal/core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application>
<service
android:name="com.onesignal.core.services.SyncService"
android:stopWithTask="true"
android:exported="false" />

<service
android:name="com.onesignal.core.services.SyncJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import android.os.Bundle
import android.os.Looper
import android.text.TextUtils
import androidx.annotation.Keep
import androidx.core.app.JobIntentService
import androidx.core.app.NotificationManagerCompat
import androidx.legacy.content.WakefulBroadcastReceiver
import androidx.core.content.ContextCompat
import com.onesignal.core.internal.application.IApplicationService
import com.onesignal.debug.internal.logging.Logging
import java.util.Random
Expand Down Expand Up @@ -42,14 +41,6 @@ object AndroidUtils {
return hasToken && insetsAttached
}

fun sleep(ms: Int) {
try {
Thread.sleep(ms.toLong())
} catch (e: InterruptedException) {
e.printStackTrace()
}
}

fun hasConfigChangeFlag(
activity: Activity,
configChangeFlag: Int,
Expand Down Expand Up @@ -147,25 +138,8 @@ object AndroidUtils {
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}
return Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
}

fun hasJobIntentService(): Boolean {
return try {
// noinspection ConstantConditions
JobIntentService::class.java != null
} catch (e: Throwable) {
false
}
}

fun hasWakefulBroadcastReceiver(): Boolean {
return try {
// noinspection ConstantConditions
WakefulBroadcastReceiver::class.java != null
} catch (e: Throwable) {
false
}
// Default to minSDK version if we can't find the target version
return Build.VERSION_CODES.LOLLIPOP
}

fun hasNotificationManagerCompat(): Boolean {
Expand Down Expand Up @@ -248,7 +222,7 @@ object AndroidUtils {
true
} else {
val permissionGrant =
AndroidSupportV4Compat.ContextCompat.checkSelfPermission(
ContextCompat.checkSelfPermission(
applicationService.appContext,
permission,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ object ViewUtils {
fun getWindowHeight(activity: Activity): Int {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getWindowHeightAPI23Plus(activity)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindowHeightLollipop(
activity,
)
} else {
getDisplaySizeY(activity)
getWindowHeightLollipop(activity)
}
}

Expand Down
Loading