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
8 changes: 8 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ jobs:
sed -i '' "s/^version:.*/version: $NEW_VERSION/" pubspec.yaml
echo "✓ Updated pubspec.yaml version to ${NEW_VERSION}"

# Update podspec version
sed -i '' "s|s\.version[[:space:]]*=[[:space:]]*'[^']*'|s.version = '${NEW_VERSION}'|" ios/onesignal_flutter.podspec
echo "✓ Updated ios/onesignal_flutter.podspec version to ${NEW_VERSION}"

# Update android build.gradle version
sed -i '' "s|^version '[^']*'|version '${NEW_VERSION}'|" android/build.gradle
echo "✓ Updated android/build.gradle version to ${NEW_VERSION}"

# Update OneSignalPlugin.java wrapper version
sed -i '' "s/OneSignalWrapper\.setSdkVersion(\"[^\"]*\")/OneSignalWrapper.setSdkVersion(\"$WRAPPER_VERSION\")/g" android/src/main/java/com/onesignal/flutter/OneSignalPlugin.java

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.onesignal.flutter'
version '5.3.4'
version '5.5.0'

buildscript {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private void init(Context context, BinaryMessenger messenger) {
this.messenger = messenger;
OneSignalWrapper.setSdkType("flutter");
// For 5.0.0, hard code to reflect SDK version
OneSignalWrapper.setSdkVersion("050406");
OneSignalWrapper.setSdkVersion("050500");

channel = new MethodChannel(messenger, "OneSignal");
channel.setMethodCallHandler(this);
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Flutter (1.0.0)
- onesignal_flutter (5.3.4):
- onesignal_flutter (5.5.0):
- Flutter
- OneSignalXCFramework (= 5.5.0)
- OneSignalXCFramework (5.5.0):
Expand Down Expand Up @@ -78,7 +78,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
onesignal_flutter: fa28e94a7baa3cd8b503fc4d760103405882f47f
onesignal_flutter: 786a2ae8d69120f3041f0f1de326bee63b319e3e
OneSignalXCFramework: 943852e7d70d719f73e9669d48620aeec1b93022
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
Expand Down
12 changes: 0 additions & 12 deletions examples/demo/lib/widgets/sections/live_activities_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ class _LiveActivitiesSectionState extends State<LiveActivitiesSection> {
: () => vm.updateLiveActivity(),
),
AppSpacing.gapBox,
SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: activityEmpty ? null : () => vm.exitLiveActivity(),
style: OutlinedButton.styleFrom(
foregroundColor: AppColors.osPrimary,
side: const BorderSide(color: AppColors.osPrimary),
),
child: const Text('STOP UPDATING LIVE ACTIVITY'),
),
),
AppSpacing.gapBox,
SizedBox(
width: double.infinity,
child: OutlinedButton(
Comment on lines 82 to 87
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 The PR removes the STOP UPDATING LIVE ACTIVITY button from the UI but leaves behind dead code: exitLiveActivity() in app_viewmodel.dart (lines 504-507) and onesignal_repository.dart (lines 195-198) have no remaining callers. Additionally, onesignal_repository.dart calls OneSignal.LiveActivities.exitLiveActivity() -- the method marked @deprecated in this same PR -- without a suppress comment, producing a build warning when the demo app is compiled.

Extended reasoning...

What the bug is

This PR removes the STOP UPDATING LIVE ACTIVITY button from live_activities_section.dart (lines 82-87 in the diff). That button called vm.exitLiveActivity() in the viewmodel. However, the removal was not propagated down the calling chain: the exitLiveActivity() methods in both examples/demo/lib/viewmodels/app_viewmodel.dart (lines 504-507) and examples/demo/lib/repositories/onesignal_repository.dart (lines 195-198) were left intact with no remaining UI callers, making them dead code.

The specific code path that triggers it

Before this PR: UI button calls vm.exitLiveActivity(), which calls _repository.exitLiveActivity(), which calls OneSignal.LiveActivities.exitLiveActivity(activityId). After this PR, the UI button is removed but the entire chain below it remains. Searching the demo app lib directory for callers of vm.exitLiveActivity() returns only the method definition itself -- confirming it is unreachable dead code. There is a second distinct issue: onesignal_repository.dart line 197 calls OneSignal.LiveActivities.exitLiveActivity(activityId) -- the exact method marked @deprecated in this same PR -- without any suppress comment.

Why existing code does not prevent it

There is no static analysis rule or linting configuration in the demo app that flags unreachable instance methods. The Dart analyzer does not treat public instance methods as dead code even when no callers exist, so the compiler will not emit a warning about the orphaned viewmodel and repository methods. The missing suppress comment in onesignal_repository.dart is separately noteworthy because the test file at test/liveactivities_test.dart correctly added the suppress comment before its call to the same deprecated method, demonstrating the project is aware of the requirement -- but the demo repository was not updated consistently.

Impact

The impact is limited to the demo app example code and does not affect the core SDK. The dead code creates maintenance confusion, and building the demo app will emit a Dart deprecation warning at onesignal_repository.dart:197 because exitLiveActivity was marked @deprecated in this exact PR. While not a runtime failure, the warning is a direct inconsistency introduced by this PR and is avoidable.

How to fix

Remove exitLiveActivity() from both app_viewmodel.dart (lines 504-507) and onesignal_repository.dart (lines 195-198). If the methods are intentionally retained for possible future use, add the appropriate ignore comment to the call in onesignal_repository.dart to suppress the warning. The cleaner approach is full removal since the UI entry point is gone.

Step-by-step proof

  1. Before this PR, live_activities_section.dart contained a button with onPressed: () => vm.exitLiveActivity().
  2. This PR removes that button entirely (diff lines 82-94 in live_activities_section.dart).
  3. app_viewmodel.dart:504-507 still defines exitLiveActivity() calling _repository.exitLiveActivity() -- no other call site exists in the demo app.
  4. onesignal_repository.dart:195-198 still defines exitLiveActivity() calling OneSignal.LiveActivities.exitLiveActivity(activityId) -- no other call site exists.
  5. lib/src/liveactivities.dart now marks exitLiveActivity with @deprecated('Currently unsupported, avoid using this method.').
  6. Running dart analyze on the demo app will produce a deprecated_member_use warning at onesignal_repository.dart:197 because there is no suppress comment, unlike test/liveactivities_test.dart which correctly has the ignore comment.

Expand Down
2 changes: 1 addition & 1 deletion ios/onesignal_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'onesignal_flutter'
s.version = '5.3.4'
s.version = '5.5.0'
s.summary = 'The OneSignal Flutter SDK'
s.description = 'Allows you to easily add OneSignal to your flutter projects, to make sending and handling push notifications easy'
s.homepage = 'https://www.onesignal.com'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ + (instancetype)sharedInstance {
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {

OneSignalWrapper.sdkType = @"flutter";
OneSignalWrapper.sdkVersion = @"050406";
OneSignalWrapper.sdkVersion = @"050500";
[OneSignal initialize:nil withLaunchOptions:nil];

OneSignalPlugin.sharedInstance.channel =
Expand Down
3 changes: 2 additions & 1 deletion lib/src/liveactivities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class OneSignalLiveActivities {
// private channels used to bridge to ObjC/Java
MethodChannel _channel = const MethodChannel('OneSignal#liveactivities');

/// Indicate this device has exited a live activity, identified within OneSignal by the [activityId]. The
/// Indicate this device has entered a live activity, identified within OneSignal by the [activityId]. The
/// [token] is the ActivityKit's update token that will be used to update the live activity.
///
/// Only applies to iOS.
Expand All @@ -19,6 +19,7 @@ class OneSignalLiveActivities {
/// Indicate this device has exited a live activity, identified within OneSignal by the [activityId].
///
/// Only applies to iOS.
@Deprecated('Currently unsupported, avoid using this method.')
Future<void> exitLiveActivity(String activityId) async {
Comment on lines +22 to 23
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 The @Deprecated annotation on exitLiveActivity uses a two-line format but its message (49 chars) fits on a single line within the 80-char limit, so dart format will collapse it and cause the CI format-check step to fail with a non-zero exit code. Fix: use @Deprecated('Currently unsupported, avoid using this method.') on a single line.

Extended reasoning...

What the bug is

In lib/src/liveactivities.dart lines 22–23, the newly added @Deprecated annotation is written in multi-line form:

  @Deprecated(
      'Currently unsupported, avoid using this method.')

The deprecation message is 49 characters. The full single-line annotation with two leading spaces would be @Deprecated('Currently unsupported, avoid using this method.') — exactly 64 characters — well within dart format's default 80-character line limit.

The specific code path that triggers it

The CI workflow runs dart run rps format-check (defined in pubspec.yaml under scripts.format-check), which expands to:

dart format --set-exit-if-changed --output=none lib test

dart format normalizes single-argument function-like expressions (including annotations) to a single line whenever they fit within the line limit. Because the single-line form is only 64 characters, dart format would reformat lines 22–23 into one line. With --set-exit-if-changed, this causes the format-check step to exit non-zero, failing CI.

Why existing code does not prevent it

There is no pre-commit hook or editor integration enforcing dart format before changes are pushed. The commit history shows the root cause: commit 111e903 style: reformat deprecated annotation originally had a longer message that dart format kept multi-line, then commit ae0f975 docs: soften exitLiveActivity deprecation message shortened the message without collapsing the multi-line form to match what dart format would produce.

The contrast with the existing @Deprecated in lib/onesignal_flutter.dart (lines 73–74) is telling: that annotation's message is 123 characters long, so its multi-line form is correct and dart format leaves it as-is. The new annotation has a much shorter message that must be on one line.

Impact

Every CI run against this PR (or any branch that contains this file state) will fail the format-check step. This blocks merging through CI until the annotation is reformatted.

How to fix it

Change lines 22–23 to single-line:

  @Deprecated('Currently unsupported, avoid using this method.')

Step-by-step proof

  1. lib/src/liveactivities.dart lines 22–23 contain the two-line @Deprecated form.
  2. CI triggers the format-check script: dart format --set-exit-if-changed --output=none lib test.
  3. dart format processes lib/src/liveactivities.dart and determines the annotation fits on one line (64 chars ≤ 80 chars).
  4. dart format would reformat the file — meaning the file content differs from what is on disk.
  5. Because --set-exit-if-changed is set and the file would change, dart format exits with a non-zero status code.
  6. The CI step fails, blocking the PR from passing its required checks.

if (defaultTargetPlatform == TargetPlatform.iOS) {
return await _channel.invokeMethod(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: onesignal_flutter
description: OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
version: 5.4.6
version: 5.5.0
homepage: https://github.com/OneSignal/OneSignal-Flutter-SDK

# Uses rps package for scripts
Expand Down
1 change: 1 addition & 0 deletions test/liveactivities_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void main() {

group('exitLiveActivity', () {
test('invokes OneSignal#exitLiveActivity with activityId', () async {
// ignore: deprecated_member_use_from_same_package
await liveActivities.exitLiveActivity(activityId);

expect(channelController.state.liveActivityExited, true);
Expand Down
Loading