Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Looking for Feedback] OneSignal Flutter SDK 5.0.0-beta1 Released! #667

Closed
1 task done
fhboswell opened this issue Mar 3, 2023 · 9 comments
Closed
1 task done

Comments

@fhboswell
Copy link
Contributor

fhboswell commented Mar 3, 2023

What's on your mind?

In this major version beta release for the OneSignal SDK, we are making a significant shift from a device-centered model to a user-centered model. A user-centered model allows for more powerful omni-channel integrations within the OneSignal platform.

For more information please see the migration guide.

🚧 Beta release. It is not recommended to use in production. 🚧

Please post any feedback related to the beta here!

Code of Conduct

  • I agree to follow this project's Code of Conduct
@fhboswell fhboswell pinned this issue Mar 3, 2023
@xvrh
Copy link

xvrh commented Mar 23, 2023

I'm trying to make the migration but I run into issue during the Flutter build for iOS.

It seems I have to update OneSignalXCFramework version in podspec to allow v5.
Then NotificationService.swift file becomes invalid (I have an error No such module 'OneSignal').

@fhboswell is there an updated documentation on how to setup Flutter/iOS project?
https://documentation.onesignal.com/v11.0/docs/ios-sdk-setup doesn't seem updated.

Thanks.

@jfishman1
Copy link

Hello, for the flutter SDK, you can use: https://documentation.onesignal.com/v11.0/docs/flutter-sdk-setup

But this is still in beta so things will be updating/changing until GA.

@xvrh
Copy link

xvrh commented Mar 30, 2023

Thanks for the documentation.

Here is some crashes we are seeing in the wild on Android:

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.onesignal.notifications.receivers.FCMBroadcastReceiver: java.lang.Exception: Service class zf.b could not be instantiated
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:3413)
       at android.app.ActivityThread.-wrap18()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1807)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:7000)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

Caused by java.lang.Exception: Service class zf.b could not be instantiated
       at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.java:58)
       at com.onesignal.internal.OneSignalImp.initWithContext(OneSignalImp.java:77)
       at com.onesignal.OneSignal.initWithContext(OneSignal.java:12)
       at com.onesignal.notifications.receivers.FCMBroadcastReceiver.onReceive(FCMBroadcastReceiver.java:31)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:3406)
       at android.app.ActivityThread.-wrap18()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1807)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:7000)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

Any idea?

@krunalappdev
Copy link

Getting No such module 'OneSignal' after migrating to v5.

@andredealmei
Copy link

Not working in release mode after upgrade to v5

@Toolenaar
Copy link

Getting the same error "No such module 'OneSignal' after migrating to v5.". Anyone know a workaround?

@Toolenaar
Copy link

Ahh I found the solution. The documentation is wrong. In the NotificationService swift file OneSignalshould be replaced withOneSignalExtension

Complete file:

import UserNotifications

import OneSignalExtension

class NotificationService: UNNotificationServiceExtension {
    
    var contentHandler: ((UNNotificationContent) -> Void)?
    var receivedRequest: UNNotificationRequest!
    var bestAttemptContent: UNMutableNotificationContent?
    
    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.receivedRequest = request
        self.contentHandler = contentHandler
        self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
        
        if let bestAttemptContent = bestAttemptContent {
            //If your SDK version is < 3.5.0 uncomment and use this code:
            /*
            OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
            */
            
            /* DEBUGGING: Uncomment the 2 lines below to check this extension is excuting
                          Note, this extension only runs when mutable-content is set
                          Setting an attachment or action buttons automatically adds this */
            //OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)
            //bestAttemptContent.body = "[Modified] " + bestAttemptContent.body
            
            OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)
        }
    }
    
    override func serviceExtensionTimeWillExpire() {
        // Called just before the extension will be terminated by the system.
        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
            OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    }
    
}

@vaetas
Copy link

vaetas commented Sep 11, 2023

The Swift code @Toolenaar pasted was missing from the MIGRATION guide and the docs are not updated yet. Example project in this package uses ObjC which was not useful. Other than that I could migrate easily using the guide.

@fhboswell is there a reason that the Swift code change is not mentioned in the migration document? Thanks

@M2dL1fe
Copy link

M2dL1fe commented Dec 27, 2023

Caused by java.lang.NullPointerException

com.onesignal.core.internal.application.impl.ApplicationService.getAppContext (ApplicationService.kt:39)
com.onesignal.core.internal.device.impl.DeviceService.packageInstalledAndEnabled (DeviceService.kt:106)
com.onesignal.core.internal.device.impl.DeviceService.isGMSInstalledAndEnabled (DeviceService.kt:101)
com.onesignal.core.internal.device.impl.DeviceService.supportsGooglePush (DeviceService.kt:84)
com.onesignal.core.internal.device.impl.DeviceService.getDeviceType (DeviceService.kt:41)
com.onesignal.core.internal.device.impl.DeviceService.isAndroidDeviceType (DeviceService.kt:18)
com.onesignal.location.LocationModule$register$1.invoke (LocationModule.kt:31)
com.onesignal.location.LocationModule$register$1.invoke (LocationModule.kt:28)
com.onesignal.common.services.ServiceRegistrationLambda.resolve (ServiceRegistration.kt:164)
com.onesignal.common.services.ServiceProvider.getServiceOrNull (ServiceProvider.kt:79)
com.onesignal.common.services.ServiceProvider.getService (ServiceProvider.kt:67)
com.onesignal.common.services.ServiceRegistrationReflection.resolve (ServiceRegistration.kt:82)
com.onesignal.common.services.ServiceProvider.getServiceOrNull (ServiceProvider.kt:79)
com.onesignal.common.services.ServiceProvider.getService (ServiceProvider.kt:67)
com.onesignal.common.services.ServiceRegistrationReflection.resolve (ServiceRegistration.kt:82)
com.onesignal.common.services.ServiceProvider.getServiceOrNull (ServiceProvider.kt:79)
com.onesignal.common.services.ServiceProvider.getService (ServiceProvider.kt:67)
com.onesignal.common.services.ServiceProvider.getService$com_onesignal_core (ServiceProvider.kt:39)
com.onesignal.internal.OneSignalImp.initWithContext (OneSignalImp.kt:223)
com.onesignal.OneSignal.initWithContext (OneSignal.kt:208)
com.onesignal.notifications.receivers.FCMBroadcastReceiver.onReceive (FCMBroadcastReceiver.kt:26)
android.app.ActivityThread.handleReceiver (ActivityThread.java:4476)

@jkasten2 jkasten2 unpinned this issue Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants