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

Migrating to null-safety #90

Merged
merged 6 commits into from
Apr 22, 2021
Merged

Conversation

GaspardMerten
Copy link

A PR to migrate this plugin to null safety.

@GaspardMerten
Copy link
Author

@DennisAlund

@jaumard jaumard mentioned this pull request Mar 18, 2021
Copy link
Member

@DennisAlund DennisAlund left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution. Please walk through the log event calls and make sure that we use required / "not nullable" where it is supposed to be. As opposed to adding support for non-nullable but making all parameters nullable, which effectively is the same as not adding the support.

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -165,7 +164,7 @@ class FacebookAppEvents {
/// Parameter [registrationMethod] is used to specify the method the user has
/// used to register for the app, e.g. "Facebook", "email", "Google", etc.
/// See: https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/appevents/appeventsconstants.html/#eventnamecompletedregistration
Future<void> logCompletedRegistration({String registrationMethod}) {
Future<void> logCompletedRegistration({String? registrationMethod}) {
Copy link
Member

Choose a reason for hiding this comment

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

I think registrationMethod is required

/**
 * This function assumes logger is an instance of AppEventsLogger and has been
 * created using AppEventsLogger.newLogger() call.
 */
public void logCompleteRegistrationEvent (String registrationMethod) {
    Bundle params = new Bundle();
    params.putString(AppEventsConstants.EVENT_PARAM_REGISTRATION_METHOD, registrationMethod);
    logger.logEvent(AppEventsConstants.EVENT_NAME_COMPLETED_REGISTRATION, params);
}

Copy link
Author

Choose a reason for hiding this comment

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

I just had a look at the source code of one of my app currently on the market, and I am not using the default parameter name for the signup method, which leads me to think that it is not really required. (I was using "method" instead of "fb_registration_method" and it worked for the past few months)

Copy link
Member

Choose a reason for hiding this comment

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

Before null saftey it was a developer interpretation choice... but now with null safety it will be comedictated by the design of the plugin. So it would be good to find clear documentation from Facebook SDK definition.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @DennisAlund, I found out that an event's parameters are always optional! Of course, this is only true for the events being logged through the logEvent method. (https://developers.facebook.com/docs/app-events/overview)

So the registrationMethod parameter should not be required since that would mean adding a constraint that Facebook does not require.

Choose a reason for hiding this comment

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

@GaspardMerten agree, here you can see the official documentation by Facebook in Swift

https://developers.facebook.com/docs/swift/reference/structs/appevent.html

public static func completedRegistration(registrationMethod:String?=nil, valueToSum:Double?=nil, extraParameters:ParametersDictionary=[:])
Method Name Description
registrationMethod Optional registration method used.
valueToSum Optional value to sum.
extraParameters Optional dictionary of extra parameters.

pubspec.yaml Outdated Show resolved Hide resolved
@DennisAlund DennisAlund changed the title Migrating to null-safety (v0.2.0) Migrating to null-safety Mar 26, 2021
@RicardoRB
Copy link

@DennisAlund Would it be possible to merge this and create a new version? I would love to upgrade my project to flutter null-safety :)

@Manguelo
Copy link

Manguelo commented Apr 13, 2021

Any news on this? For now I'll just point my pub package to the changed branch.

@yanivshaked
Copy link
Contributor

Hi,
I'm using @GaspardMerten branch, but getting a crash on the first application start after clean install (see logs below).
Was this issue fixed on the master branch?
@GaspardMerten Can you pull the master branch changes into your null safety branch?

Thanks,
Yaniv


Incident Identifier: EDE83875-7675-4F03-97D4-7328A2D07DFD
Hardware Model:      iPhone13,3
Process:             Runner [13188]
Path:                /private/var/containers/Bundle/Application/A77BA585-46A2-4F45-9440-7403EE11EC89/Runner.app/Runner
Identifier:          com.twtech.twelveqa
Version:             2705 (0.12.402)
AppStoreTools:       12D4d
AppVariant:          1:iPhone13,3:14
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.twtech.twelveqa [1140]


Date/Time:           2021-04-14 10:52:27.9057 +0300
Launch Time:         2021-04-14 10:52:24.5686 +0300
OS Version:          iPhone OS 14.4.2 (18D70)
Release Type:        User
Baseband Version:    1.42.03
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000189e35550
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [13188]
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libdispatch.dylib             	0x0000000189e35550 _dispatch_once_wait.cold.1 + 28 (lock.c:674)
1   libdispatch.dylib             	0x0000000189e02708 _dispatch_once_wait + 196 (lock.c:674)
2   FBSDKCoreKit                  	0x0000000102e09ca0 _dispatch_once + 16 (once.h:84)
3   FBSDKCoreKit                  	0x0000000102e09ca0 +[FBSDKAppEvents singleton] + 112 (FBSDKAppEvents.m:929)
4   FBSDKCoreKit                  	0x0000000102e09afc +[FBSDKAppEvents logInternalEvent:valueToSum:parameters:isImplicitlyLogged:accessToken:] + 128 (FBSDKAppEvents.m:905)
5   FBSDKCoreKit                  	0x0000000102e09930 +[FBSDKAppEvents logInternalEvent:parameters:isImplicitlyLogged:] + 76 (FBSDKAppEvents.m:867)
6   FBSDKCoreKit                  	0x0000000102e6338c 0x102e00000 + 406412
7   libobjc.A.dylib               	0x000000019f221c58 CALLING_SOME_+initialize_METHOD + 24 (objc-initialize.mm:384)
8   libobjc.A.dylib               	0x000000019f228318 initializeNonMetaClass + 716 (objc-initialize.mm:554)
9   libobjc.A.dylib               	0x000000019f229910 initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) + 280 (objc-runtime-new.mm:2221)
10  libobjc.A.dylib               	0x000000019f238498 lookUpImpOrForward + 956 (objc-runtime-new.mm:2237)
11  libobjc.A.dylib               	0x000000019f222524 _objc_msgSend_uncached + 68
12  FBSDKCoreKit                  	0x0000000102e0d5c4 +[FBSDKAppEventsConfigurationManager loadAppEventsConfigurationWithBlock:] + 84 (FBSDKAppEventsConfigurationManager.m:61)
13  FBSDKCoreKit                  	0x0000000102e0ac90 -[FBSDKAppEvents fetchServerConfiguration:] + 120 (FBSDKAppEvents.m:1082)
14  FBSDKCoreKit                  	0x0000000102e07e4c -[FBSDKAppEvents init] + 304 (FBSDKAppEvents.m:375)
15  FBSDKCoreKit                  	0x0000000102e09cc0 __27+[FBSDKAppEvents singleton]_block_invoke + 28 (FBSDKAppEvents.m:930)
16  libdispatch.dylib             	0x0000000189e01db0 _dispatch_client_callout + 20 (object.m:559)
17  libdispatch.dylib             	0x0000000189e035c8 _dispatch_once_callout + 32 (once.c:52)
18  FBSDKCoreKit                  	0x0000000102e09ca0 _dispatch_once + 16 (once.h:84)
19  FBSDKCoreKit                  	0x0000000102e09ca0 +[FBSDKAppEvents singleton] + 112 (FBSDKAppEvents.m:929)
20  FBSDKCoreKit                  	0x0000000102e0910c +[FBSDKAppEvents setUserID:] + 76 (FBSDKAppEvents.m:714)
21  facebook_app_events           	0x0000000103a0f7e4 specialized SwiftFacebookAppEventsPlugin.handleSetUserId(_:result:) + 172 (SwiftFacebookAppEventsPlugin.swift:129)
22  facebook_app_events           	0x0000000103a0f7e4 specialized SwiftFacebookAppEventsPlugin.handleSetUserId(_:result:) + 172 (<compiler-generated>:0)
23  facebook_app_events           	0x0000000103a0f7e4 specialized SwiftFacebookAppEventsPlugin.handle(_:result:) + 3932 (<compiler-generated>:36)
24  facebook_app_events           	0x0000000103a0ddd4 specialized SwiftFacebookAppEventsPlugin.handle(_:result:) + 8 (<compiler-generated>:0)
25  facebook_app_events           	0x0000000103a0ddd4 @objc SwiftFacebookAppEventsPlugin.handle(_:result:) + 72
26  Flutter                       	0x0000000104520e60 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 116 (FlutterChannels.mm:244)
27  Flutter                       	0x0000000103f980d8 flutter::PlatformMessageRouter::HandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>) const + 140 (platform_message_router.mm:27)
28  Flutter                       	0x0000000103f980d8 flutter::PlatformViewIOS::HandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>) + 504 (platform_view_ios.mm:76)
29  Flutter                       	0x0000000104294f8c flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_36::operator()() const + 88 (shell.cc:1184)
30  Flutter                       	0x0000000104294f8c decltype(std::__1::forward<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_36&>(fp)()) std::__1::__invoke<flutter::Shell::OnEngineHandlePlatformMessage(fml::... + 88 (type_traits:4425)
31  Flutter                       	0x0000000104294f8c void std::__1::__invoke_void_return_wrapper<void>::__call<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_36&>(flutter::Shell::OnEngineHandlePlatformMessage(... + 88 (__functional_base:348)
32  Flutter                       	0x0000000104294f8c std::__1::__function::__alloc_func<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_36, std::__1::allocator<flutter::Shell::OnEngineHandlePlatformMessage(fml:... + 88 (functional:1533)
33  Flutter                       	0x0000000104294f8c std::__1::__function::__func<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPtr<flutter::PlatformMessage>)::$_36, std::__1::allocator<flutter::Shell::OnEngineHandlePlatformMessage(fml::RefPt... + 108 (functional:1707)
34  Flutter                       	0x0000000104235d94 std::__1::__function::__value_func<void ()>::operator()() const + 12 (functional:1860)
35  Flutter                       	0x0000000104235d94 std::__1::function<void ()>::operator()() const + 12 (functional:2419)
36  Flutter                       	0x0000000104235d94 fml::MessageLoopImpl::FlushTasks(fml::FlushType) + 1444 (message_loop_impl.cc:130)
37  Flutter                       	0x0000000104237bf4 fml::MessageLoopImpl::RunExpiredTasksNow() + 8 (message_loop_impl.cc:143)
38  Flutter                       	0x0000000104237bf4 fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*) + 32 (message_loop_darwin.mm:75)
39  CoreFoundation                	0x000000018a189fa0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32 (CFRunLoop.c:1807)
40  CoreFoundation                	0x000000018a189ba0 __CFRunLoopDoTimer + 1064 (CFRunLoop.c:2415)
41  CoreFoundation                	0x000000018a188ffc __CFRunLoopDoTimers + 328 (CFRunLoop.c:2575)
42  CoreFoundation                	0x000000018a182ee4 __CFRunLoopRun + 1936 (CFRunLoop.c:3090)
43  CoreFoundation                	0x000000018a18221c CFRunLoopRunSpecific + 600 (CFRunLoop.c:3242)
44  GraphicsServices              	0x00000001a1d4c784 GSEventRunModal + 164 (GSEvent.c:2259)
45  UIKitCore                     	0x000000018cbc2ee8 -[UIApplication _run] + 1072 (UIApplication.m:3253)
46  UIKitCore                     	0x000000018cbc875c UIApplicationMain + 168 (UIApplication.m:4707)
47  Runner                        	0x00000001006ee8c4 main + 64 (AppDelegate.swift:6)
48  libdyld.dylib                 	0x0000000189e426b0 start + 4

@GaspardMerten
Copy link
Author

@yanivshaked, I just did it :) Let's hope the issue was resolved on the upstream repo!

@yanivshaked
Copy link
Contributor

Thanks for the super quick action!
Testing it now, will update when I have the results.

@yanivshaked
Copy link
Contributor

Issue seems to be solved 👍 👍

@lukasloh
Copy link
Contributor

lukasloh commented Apr 20, 2021

@DennisAlund Can we please get this merged in, if there is no issues?

@bradsb
Copy link

bradsb commented Apr 20, 2021

@DennisAlund This package is the only remaining blocker for my upgrade to flutter 2 with null safety. A review and merge would be greatly appreciated

@DennisAlund DennisAlund changed the base branch from master to develop April 22, 2021 00:36
@DennisAlund
Copy link
Member

Sorry for delay. Let's try it out.

@DennisAlund DennisAlund merged commit f086ffb into oddbit:develop Apr 22, 2021
@DennisAlund
Copy link
Member

Released in v0.12.0 thank you for your contribution!!! 🚀

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

Successfully merging this pull request may close these issues.

7 participants