6

I implemented Firebase App Invite in my application, I can select friends to invite, but the invitations are not sent.

In onActivityResult the resultCode is 3.

In my Firebase Project Settings I have already entered SHA1 code (release and debug certificate).

My Activity code:

public static final int REQUEST_INVITE = 65;
private static final String TAG = GeneralActivity.class.getSimpleName();

public void inviteFriends() {
    Intent intent = new AppInviteInvitation.IntentBuilder("Invitation title")
            .setMessage("Invitation message")
            .setOtherPlatformsTargetApplication(AppInviteInvitation.IntentBuilder.PlatformMode.PROJECT_PLATFORM_IOS, MY_IOS_APPID)
            .build();
    startActivityForResult(intent, REQUEST_INVITE);
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_INVITE) {
        if (resultCode == RESULT_OK) {
            String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
            for (String id : ids) {
                Log.d(TAG, "onActivityResult: sent invitation " + id);
            }
        } else {
            Log.d(TAG, "Invitation not sent");
        }
    }
}

Project Gradle:

dependencies {
         classpath 'com.android.tools.build:gradle:2.2.0'
         classpath 'com.google.gms:google-services:3.0.0'
     }

Module Gradle:

dependencies {
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.google.android.gms:play-services-ads:9.6.1'
    compile 'com.google.firebase:firebase-core:9.6.1'
    compile 'com.google.firebase:firebase-ads:9.6.1'
    compile 'com.google.firebase:firebase-crash:9.6.1'
    compile 'com.google.firebase:firebase-invites:9.6.1'
}

apply plugin: 'com.google.gms.google-services'

Why invitations do not work? How can I fix the problem?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Ettore Gallina
  • 435
  • 1
  • 3
  • 16

1 Answers1

0

The problem is here:

.setOtherPlatformsTargetApplication(AppInviteInvitation.IntentBuilder.PlatformMode.PROJECT_PLATFORM_IOS, MY_IOS_APPID)

I set the constant MY_IOS_APPID as "apple app id of my application",

instead it's the value of "Firebase client id", to find this value: https://stackoverflow.com/a/37966199/3645999


This answer was posted as an edit to the question Firebase App Invite - invitations not sent by the OP Ettore Gallina under CC BY-SA 3.0.

vvvvv
  • 25,404
  • 19
  • 49
  • 81