Facebook AppInvite Android Studio Cannot resolve method show( -


i'm developping app react native, need incorporate native module use facebook appinvite let user invite friends on app.

however, i've followed in react native's documentation add native module in react native (the link between react native , native code works), native module written in java doesn't work. https://facebook.github.io/react-native/docs/native-modules-android.html

package com.app.app;  import android.app.activity; import android.content.context; import android.graphics.bitmap;  import com.facebook.react.bridge.nativemodule; import com.facebook.react.bridge.reactapplicationcontext; import com.facebook.react.bridge.reactcontext; import com.facebook.react.bridge.reactcontextbasejavamodule; import com.facebook.react.bridge.reactmethod; import com.facebook.facebooksdk; import com.facebook.callbackmanager; import com.facebook.facebookexception; import com.facebook.share.model.appinvitecontent; import com.facebook.share.widget.appinvitedialog; import android.support.v4.app.dialogfragment;  import java.util.map; import java.util.hashmap;  public class facebookinvitemodule extends reactcontextbasejavamodule {      //cannot modified since use reactnative     public facebookinvitemodule(reactapplicationcontext reactcontext) {         super(reactcontext);     }      //cannot modified since use reactnative     @override          public string getname() {          return "facebookinvite";     }      @reactmethod      public void showmodule(){          string applinkurl, previewimageurl;          applinkurl = "https://www.app.com/myapplink";         previewimageurl = "https://www.app.com/my_invite_image.jpg";          if (appinvitedialog.canshow()) {             appinvitecontent content = new appinvitecontent.builder()                     .setapplinkurl(applinkurl)                     .setpreviewimageurl(previewimageurl)                     .build();              appinvitedialog.show(this, content);         }     } } 

nothing can pass in function showmodule() since use in javascript code show native component called in react native : nativemodules.facebookinvite.showmodule();

for code in function showmodule(), i'm using same code on official documentation of facebook : https://developers.facebook.com/docs/app-invites/android

but error : appinvitedialog.show(this, content); saying "cannot resolve method 'show(com.app.app.facebookinvitemodule, com.facebook.share.model.appinvitecontent)"

i quite know reactnative, don't know java , don't understand error. file code in same folder mainactivty , mainapplication.

so if know can make work, wonderful :d

you don't have write native component. can use official facebook library app invites. react-native-fbsdk has appinvite component. not documented has pretty explanation need inside code files. check source code , can figure out.

example

import { appinvitedialog } 'react-native-fbsdk';  appinvitedialog.canshow().then(()=> {     appinvitedialog.show({         previewimageurl,         applinkurl,         promotioncode,         promotiontext     }).then(() => { ... }); }).catch(()=> { console.error('app invite can't show!'); }); 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -