KjellConnelly / react-native-rate

Send your app users to Apple App Store, Google Play, Amazon, or other using the newest APIs
642 stars 101 forks source link

null is not an object (evaluating 'RNRate.rate') rate #51

Closed nartydev closed 4 years ago

nartydev commented 4 years ago

React Native Environment Info: System: OS: macOS 10.14.2 CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz Memory: 648.76 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.14.2 - /usr/local/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.11.2 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 19, 28, 29 Build Tools: 28.0.3, 29.0.2 System Images: android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.5 AI-191.8026.42.35.5900203 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz => 0.59.8 npmGlobalPackages: react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7

Hi, I use Expo for emulating my React Native project and i try to use the module. I tested the manual and automatic installation, the module is in the node_modules, I tried via Xcode too but always the same error. It's maybe a problem with Expo ?

ShareMenu.js

import React, { Component } from 'react';
import { containers, texts, images, buttons} from '../styles'
import { Image, Share } from 'react-native'

import { Linking } from 'react-native'
import Rate, { AndroidMarket } from 'react-native-rate'

class ShareMenu extends Component {

  constructor(props) {
    super(props)

    this.state = {
      rated: false
    }
  }

  onShare = async () => {
      try {
        const result = await Share.share({
          message:
            'React Native | A framework for building native apps using React',
        });

        if (result.action === Share.sharedAction) {
          console.log('success')
          if (result.activityType) {
            // shared with activity type of result.activityType
          } else {
            // shared
          }
        } else if (result.action === Share.dismissedAction) {
          // dismissed
        }
      } catch (error) {
        alert(error.message);
      }
  };

  render() {
    return (
        <>
            <texts.titletop mt>Nous soutenir</texts.titletop>
            <containers.inlineitems around mt>
                <buttons.contentcenterbutton onPress={() => Linking.openURL('mailto:teaserfr@gmail.com')} title="teaserfr@gmail.com">
                    <Image
                        style={{ width: 25, height: 21 }}
                        source={require("../assets/share/mail.png")}
                    />
                </buttons.contentcenterbutton>
                <buttons.contentcenterbutton onPress={()=>{
                const options = {
                    AppleAppID:"**********",
                    GooglePackageName:"com.teaser.teaserapp",
                    AmazonPackageName:"com.teaser.teaserapp",
                    preferredAndroidMarket: AndroidMarket.Google,
                    preferInApp:false,
                    openAppStoreIfInAppFails:true,
                    fallbackPlatformURL:"https://www.teaserapp.fr",
                }
                Rate.rate(options, success=>{
                    if (success) {
                        this.setState({rated:true})
                    }
                })
            }}>
                    <Image
                        style={{ width: 25, height: 24 }}
                        source={require("../assets/share/star.png")}
                    />

                </buttons.contentcenterbutton>
                <buttons.contentcenterbutton onPress={() => this.onShare()}>
                    <Image
                        style={{ width: 23, height: 25 }}
                        source={require("../assets/share/share.png")}
                    />

                </buttons.contentcenterbutton>
                <buttons.contentcenterbutton onPress={() => Linking.openURL('instagram://user?username=teasergame')}>
                    <Image
                        style={{ width: 25, height: 25 }}
                        source={require("../assets/share/like.png")}
                    />
                </buttons.contentcenterbutton>
            </containers.inlineitems>
        </>
    );
  }
}

export default ShareMenu;
KjellConnelly commented 4 years ago

Did you detach from Expo? This module uses native code and thus requires you to detach first.

KjellConnelly commented 4 years ago

And if you did detach, what's the error you're getting?

nartydev commented 4 years ago

image @KjellConnelly Same error.. I have eject, and i put it in podfile : pod 'RNRate', :path => '../node_modules/react-native-rate' and a pod install in ios folder

galenweber commented 4 years ago

Just to chime in: I'm receiving the same error that @nartydev is.

tylermakin commented 4 years ago

I had this same issue and was able to remedy it by re-installing cocoapods, then making sure that pod 'RNRate', :path => '../node_modules/react-native-rate' was in my podfile, then running pod install in the /ios folder of my react project.

It did not run right away, but after I closed the app and re-installed it using Xcode everything started working again.

nartydev commented 4 years ago

It doesn't work for me, i have the same error but when i try brew install cocoapods i have this error : Error: Permission denied @ apply2files - /usr/local/share/Library/Caches/Yarn/v4/npm-react-native-gesture-handler-1.0.17-a046f371f277092157fc2781323d35a02a93daaf/node_modules/react-native-gesture-handler/ios/.DS_Store


Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pod
Target /usr/local/bin/pod
already exists. You may want to remove it:
  rm '/usr/local/bin/pod'

To force the link and overwrite all conflicting files:
  brew link --overwrite cocoapods

To list all files that would be deleted:
  brew link --overwrite --dry-run cocoapods

Possible conflicting files are:
/usr/local/bin/pod
/usr/local/bin/xcodeproj
glintpursuit commented 4 years ago

We too got same issue.

Below is brief log

null is not an object (evaluating 'RNRate.rate')

rate en-IN.js:1:23796 onPress Header.js:220:38 touchableHandlePress TouchableOpacity.js:211:45 _performSideEffectsForTransition Touchable.js:860:34 _receiveSignal Touchable.js:764:44 touchableHandleResponderRelease Touchable.js:475:24 invokeGuardedCallbackImpl ReactNativeRenderer-dev.js:93:15 invokeGuardedCallback ReactNativeRenderer-dev.js:318:36 invokeGuardedCallbackAndCatchFirstError ReactNativeRenderer-dev.js:342:30 executeDispatch ReactNativeRenderer-dev.js:715:42 executeDispatchesInOrder ReactNativeRenderer-dev.js:737:20 executeDispatchesAndRelease ReactNativeRenderer-dev.js:894:29 forEachAccumulated ReactNativeRenderer-dev.js:874:16 runEventsInBatch ReactNativeRenderer-dev.js:1050:21 runExtractedEventsInBatch ReactNativeRenderer-dev.js:1072:19

ReactNativeRenderer-dev.js:2707:6 batchedUpdates$1 ReactNativeRenderer-dev.js:17297:14 batchedUpdates ReactNativeRenderer-dev.js:2610:31 _receiveRootNodeIDEvent ReactNativeRenderer-dev.js:2705:17 receiveTouches ReactNativeRenderer-dev.js:2781:28 __callFunction MessageQueue.js:366:47 MessageQueue.js:106:26 __guard MessageQueue.js:314:10 callFunctionReturnFlushedQueue MessageQueue.js:105:17
KjellConnelly commented 4 years ago

I know this is sort of old, but I just fixed autolinking for ios. The .podspec file is now in the main directory instead of the ios folder. Should work without problems for ios now, as I just tested on a new project with react-native v0.62

luky1984 commented 3 years ago

I fixed it by calling command:

react-native link react-native-rate