urbanairship / airship-flutter

Flutter integration
Other
17 stars 17 forks source link

Annotate background message handler with @pragma('vm:entry-point') #150

Closed cs-nuuk closed 1 year ago

cs-nuuk commented 1 year ago

What do these changes do?

With Flutter 3.3 you have to annotate methods that will be used from native code with @pragma('vm:entry-point'). I've added this annotation to _backgroundMessageIsolateCallback().

Why are these changes necessary?

When you use this plugin with Flutter 3.3 you will get the following error message with release builds.

E/flutter (27564): [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary:library 'package:airship_flutter/src/airship_flutter.dart' not found.

This happens because the compiler does not know that you call this function from native code so it removes it.

How did you verify these changes?

Build the example app as release with Flutter 3.3 and view the logs. The error message will be gone.

Anything else a reviewer should know?

rlepinski commented 1 year ago

Thanks!

I assume its fine, but if we merge this does it now require using flutter 3.3+ or is it still backwards compatible with 3.0?

cs-nuuk commented 1 year ago

I can successfully build the project with Flutter 3.0.2, so I assume this change is backwards compatible.

oristanovic commented 1 year ago

@cs-nuuk Could you please fill in this contribution agreement? https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform