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
2 changes: 1 addition & 1 deletion .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ jobs:
cd examples/demo
vp run setup
cd ios
pod install
pod update OneSignalXCFramework
)
echo "✓ Refreshed examples/demo/ios/Podfile.lock"

Expand Down
8 changes: 1 addition & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@ android {
dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"

// androidx.startup runs our OneSignalInitializer during Application.onCreate so we can register
// an ActivityLifecycleCallbacks before MainActivity.onResume fires. This avoids the cold-start
// race where ReactApplicationContext.getCurrentActivity() returns null and the OneSignal SDK
// ends up holding an ApplicationContext instead of the real Activity.
implementation 'androidx.startup:startup-runtime:1.1.1'

// api is used instead of implementation so the parent :app project can access any of the OneSignal Java
// classes if needed. Such as com.onesignal.NotificationExtenderService
//
// Exclude OkHttp from OneSignal's transitive deps: the otel module pulls in OkHttp 5.x
// (via opentelemetry-exporter-sender-okhttp) which is binary-incompatible with React Native's
// networking stack (okhttp3.internal.Util removed in 5.x). React Native already provides OkHttp 4.x.
api('com.onesignal:OneSignal:5.9.2') {
api('com.onesignal:OneSignal:5.9.3') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}

Expand Down
15 changes: 1 addition & 14 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="com.onesignal.rnonesignalandroid.OneSignalInitializer"
android:value="androidx.startup" />
</provider>
</application>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -230,23 +230,15 @@ public void invalidate() {
@Override
public void initialize(String appId) {
OneSignalWrapper.setSdkType("reactnative");
OneSignalWrapper.setSdkVersion("050406");
OneSignalWrapper.setSdkVersion("050407");

if (oneSignalInitDone) {
Logging.debug("Already initialized the OneSignal React-Native SDK", null);
return;
}

ReactApplicationContext reactContext = getReactApplicationContext();
// Prefer the Activity captured by ActivityLifecycleTracker (registered via androidx.startup
// before MainActivity.onResume), then fall back to ReactApplicationContext's accessor and
// finally the ApplicationContext. Passing the real Activity lets the OneSignal SDK populate
// ApplicationService.current immediately, so requestPermission() can launch the OS dialog
// on the first cold-start instead of waiting for the next foreground event.
Context context = ActivityLifecycleTracker.getInstance().getCurrentActivity();
if (context == null) {
context = reactContext.getCurrentActivity();
}
Context context = reactContext.getCurrentActivity();
if (context == null) {
context = reactContext.getApplicationContext();
}
Expand Down
1 change: 1 addition & 0 deletions examples/demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Environment
.env
.rn-demo-env.stamp

# OSX
#
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions examples/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -euo pipefail
ORIGINAL_DIR=$(pwd)
SDK_ROOT="$(cd ../../ && pwd)"
STAMP_FILE="$SDK_ROOT/.rn-sdk-source.stamp"
DEMO_ENV_STAMP_FILE="$ORIGINAL_DIR/.rn-demo-env.stamp"
TGZ_FILE="$SDK_ROOT/react-native-onesignal.tgz"
INSTALLED_DIR="$ORIGINAL_DIR/node_modules/react-native-onesignal"

Expand All @@ -24,6 +25,34 @@ src_hash=$(find "$SDK_ROOT/src" "$SDK_ROOT/ios" "$SDK_ROOT/android" \
| shasum \
| awk '{print $1}')

demo_env_hash=$(
{
for file in "$ORIGINAL_DIR/.env" "$ORIGINAL_DIR/babel.config.js"; do
if [ -f "$file" ]; then
shasum "$file"
else
echo "missing $file"
fi
done
} | shasum | awk '{print $1}'
)

if [ ! -f "$DEMO_ENV_STAMP_FILE" ] || [ "$(cat "$DEMO_ENV_STAMP_FILE")" != "$demo_env_hash" ]; then
echo "Demo env inputs changed, clearing Metro cache..."
rm -rf "${TMPDIR:-/tmp}"/metro-* "${TMPDIR:-/tmp}"/haste-map-* "$ORIGINAL_DIR/node_modules/.cache/metro" 2>/dev/null || true
metro_pids=$(lsof -ti tcp:8081 2>/dev/null || true)
for pid in $metro_pids; do
args=$(ps -p "$pid" -o args= 2>/dev/null || true)
case "$args" in
*react-native*|*metro*)
echo "Stopping Metro so @env values are reloaded..."
kill "$pid" 2>/dev/null || true
;;
esac
done
echo "$demo_env_hash" > "$DEMO_ENV_STAMP_FILE"
fi

# Skip the whole rebuild when:
# - the demo already has the SDK installed,
# - the cached tarball is still on disk, and
Expand Down
2 changes: 1 addition & 1 deletion ios/RCTOneSignal/RCTOneSignal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (void)initOneSignal:(NSDictionary *)launchOptions {
return;

OneSignalWrapper.sdkType = @"reactnative";
OneSignalWrapper.sdkVersion = @"050406";
OneSignalWrapper.sdkVersion = @"050407";
// initialize the SDK with a nil app ID so cold start click listeners can be
// triggered
[OneSignal initialize:nil withLaunchOptions:launchOptions];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-onesignal",
"version": "5.4.6",
"version": "5.4.7",
"description": "React Native OneSignal SDK",
"keywords": [
"android",
Expand Down
2 changes: 1 addition & 1 deletion react-native-onesignal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ Pod::Spec.new do |s|

install_modules_dependencies(s)

s.dependency 'OneSignalXCFramework', '5.5.1'
s.dependency 'OneSignalXCFramework', '5.5.2'
end
Loading