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

logViewContent error: values are not NSStrings or NSNumbers #73

Closed
reesz opened this issue Jan 15, 2021 · 3 comments
Closed

logViewContent error: values are not NSStrings or NSNumbers #73

reesz opened this issue Jan 15, 2021 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@reesz
Copy link

reesz commented Jan 15, 2021

Expected Behavior

Expected the logged event to go through and show up in the events debugger.

Current Behavior

Event doesn't show up and XCode console shows the following error:

FBSDKLog: The values in the parameters dictionary must be NSStrings or NSNumbers, '{
    title = test;
}' is not.

Possible Solution

Since I don't really know why a simple string wouldn't qualify as a NSString, I can't give any good solution.
I don't know Object-C but just from reading the check that produces this error: FBSDKAppEvent.m:1198 reads:
if (![obj isKindOfClass:[NSString class]] && ![obj isKindOfClass:[NSNumber class]]) {

for some reason the obj variable holds the whole dictionary instead of just the value ("test") so it's not checking the actual values of the content Map provided, but the whole Map in dictionary format.

Steps to Reproduce (for bugs)

  1. Install version 0.8.2
  2. Update deployment target to allow build on iOS
  3. Initiate:
final facebookAppEvents = FacebookAppEvents();
  1. logViewContent:
facebookAppEvents
        .logViewContent(
          id: 'ID_HERE',
          type: 'TYPE_HERE',
          content: {
             'title': 'test'
          },
        );

Context

After implementing the plugin according to the example neither the automatic events (App Install etc.) nor the logged events showed up in the Facebook Event Debugger. The XCode console showed the following error on the logViewContent:

FBSDKLog: The values in the parameters dictionary must be NSStrings or NSNumbers, '{
    title = test;
}' is not.

As you can see I tried to simplify the submitted value to "test" to ensure it's just a basic String.
I've found a similar issue here: #27
which was suggested to be fixed, but seems not to.

Your Environment

  • Output from flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.7 19H2 darwin-x64, locale de-DE)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[!] Android Studio (version 4.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.52.1)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.
  • Operating System and version:
    MacOS Catalina 10.15.7 developing for iOS.
@reesz
Copy link
Author

reesz commented Jan 26, 2021

I've got some more insights to where this is happening. I noticed that the line I mentioned was from the Facebook iOS SDK not this plugin.
The bug lies in: facebook_app_events.dart:197 because this error only shows up, if the predefined logViewContent method is used. If I track the ViewContent event manually via:

facebookAppEvents.logEvent(
      name: FacebookAppEvents.eventNameViewedContent,
      parameters: {
        FacebookAppEvents.paramNameContentType: 'TYPE_HERE',
        FacebookAppEvents.paramNameContentId: 'ID_HERE',
        'title': 'test,
      },
    );

everything works fine.

The bug is that logViewContent accepts a String-Map as parameters, but instead of merging the Map with the already constructed map:

parameters: {
        paramNameContent: content,
        paramNameContentId: id,
        paramNameContentType: type,
      },

the plugin tries to place the Map as a Map-value in the property content. These values can only be NSStrings oder NSNumbers.
Either the content variable would've to be encoded as JSON – but since this defeats the purpose of passing parameters to be used in the Facebook analytics dashboard – the correct way should be to make content a String/Number variable and allow a second parameter additionalParameters or just parameters which is merged with the pre-defined Map.

For some reason the tracked events on iOS don't show up in the event debugger – but the same codebase on Android does, but that's something for another issue and might be related to the iOS14 privacy updates?

@DennisAlund
Copy link
Member

Thanks for bringing this to attention, I see the issue and where it went wrong

The definition of EVENT_PARAM_CONTENT is indeed that it should be a JSON encoded string.

DennisAlund added a commit that referenced this issue Mar 9, 2021
@DennisAlund
Copy link
Member

Fixed in 22e254a

MagTuxGit added a commit to MagTuxGit/flutter_facebook_app_events that referenced this issue Mar 19, 2021
* master_up:
  Bumping version
  Fixing issue oddbit#73
  Updating readme with discussions
  Fixing CHANGELOG
  Bumping version 0.9.0
  Formatting
  Formatting
  Removing resource files
  PR fixes
  Upgrading facebook-core to 9.0.0
  Upgrading FBSDKCoreKit to 9.0.0
  fix typing error
  pubspec update
  fix stupid errors
  changes to get my local working
  additional feature to support iOS14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants