Petrescu Silviu
Petrescu Silviu

Reputation: 247

How to integrate app Invites for Android with Facebook?

I'm quite new to Android and I don't quite understand importing classes so please point me in the right direction. I've added the Facebook SDK to my project via Gradle.

compile 'com.facebook.android:facebook-android-sdk:[4,5)'

In my Java class, I have the following imports:

import com.facebook.FacebookSdk;
import com.facebook.appevents.*;

When I add the following code from this link:

String appLinkUrl, previewImageUrl;

appLinkUrl = "https://www.example.com/myapplink";
previewImageUrl = "https://www.example.com/my_invite_image.jpg";

if (AppInviteDialog.canShow()) {
    AppInviteContent content = new AppInviteContent.Builder()
        .setApplinkUrl(appLinkUrl)
        .setPreviewImageUrl(previewImageUrl)
        .build();
    AppInviteDialog.show(this, content);
}

The app throws the following errors:

Error: cannot find symbol variable AppInviteDialog
Error: cannot find symbol variable AppInviteContent

What do I need to import/modify for this to work correctly?

Upvotes: 1

Views: 219

Answers (2)

Jaap
Jaap

Reputation: 1

If you have already the 2 imports and it won't work, try adding this in your build.gradle of your app:

compile 'com.facebook.android:facebook-android-sdk:4.23.0'

Upvotes: 0

John O'Reilly
John O'Reilly

Reputation: 10330

you also need following imports....in general IDEs like Android Studio will give you option to add these imports

import com.facebook.share.model.AppInviteContent;
import com.facebook.share.widget.AppInviteDialog;

Upvotes: 1

Related Questions