KeepAwake native widget error

1
Hi guys, Based on the great video about creating native widgets (https://www.mendixworld.com/session/getting-started-with-react-native/ )  I tried to create a simple widget for keeping your screen awake based on this component: https://www.npmjs.com/package/expo-keep-awake but got error messages in het make it native app: TypeError: undefined is not an object (evaluating ‘r.default.activate’)     import { Component, createElement } from "react"; import React from 'react'; import { View, Text, Button } from 'react-native'; import KeepAwake from 'expo-keep-awake'; import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake'; export class KeepAwakeNative extends Component { render() { return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Button onPress={this._activate} title="Activate">Activate</Button> <Button onPress={this._deactivate} title="Deactivate">Deactivate</Button> </View> ); } _activate = () => { activateKeepAwake(); }; _deactivate = () => { deactivateKeepAwake(); }; } I dropped the code on https://github.com/pimvdnoll/KeepAwakeNative so it would be great if someone can help me with this one, it will be available in the Appstore if fixed!   thanks!
asked
1 answers
2

Hi Pim,

Did you link the library in your custom developer app? Looking at the github repo for this Library you need to follow an additional step for iOS installation, which won’t work with the Make It Native app. This step is called linking and makes sure that the Javascript code of the NPM library you use is linked to the necessary native code written in Swift or Java/Kotlin for respectively iOS and Android. https://reactnative.dev/docs/linking

If thats the case, you can create a make it native app yourself with XCode (Mac) https://docs.mendix.com/howto/mobile/how-to-devapps#4-2-ios

Once you done that, you can follow the step called Installation in Bare React Native project (as Mendix Native is not based on expo).

answered