Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Problem linking DataWedgeIntents #14

Closed
mindaugasnakrosis opened this issue Jan 19, 2021 · 2 comments
Closed

Problem linking DataWedgeIntents #14

mindaugasnakrosis opened this issue Jan 19, 2021 · 2 comments

Comments

@mindaugasnakrosis
Copy link

mindaugasnakrosis commented Jan 19, 2021

I just bought a Zebra TC21 phone and I am trying to implement DataWedge intents into my application on it.
Using expo and tried running commands:

yarn add react-native-datawedge-intents
react-native link react-native-datawedge-intents 

I get a warning:

warn Calling react-native link [packageName] is deprecated in favor of autolinking. It will be removed in the next major release.
Autolinking documentation: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md

However, I believe it links anyway. Then I run expo start --android which runs android react-native application on my connected device.

Then I get an error:
TypeError: null is not an object (evaluating 'RNDataWedgeIntents.ACTION_SOFTSCANTRIGGER')

It might be a problem with expo, so I tried running:
yarn react-native run-android

It doesn't recognise that this is an android project:

error Android project not found. Are you sure this is a React Native project?. Run CLI with --verbose flag for more details.

Any suggestions what I should try? This looked like a similar issue as #3.

However I am not using **create-react-**app.

I am using React Native 0.61

@darryncampbell
Copy link
Owner

I have never used expo before but I gave it a try...

I ran through the instructions at https://docs.expo.io/bare/exploring-bare-workflow/ to spin up a new expo app. You need to use the "bare workflow" as this app has native Android code (Intents)

I ran react-native-unimodules but I'm not certain if that was necessary
Then yarn add react-native-datawedge-intents as you had done

Then modified App.js as follows:

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import DataWedgeIntents from 'react-native-datawedge-intents';

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />

      <TouchableOpacity
        onPress={() => DataWedgeIntents.sendBroadcastWithExtras({
        action: "com.symbol.datawedge.api.ACTION",
        extras: {"com.symbol.datawedge.api.SOFT_SCAN_TRIGGER":"START_SCANNING"}})}
        style={{ backgroundColor: 'blue' }}>
        <Text style={{ fontSize: 20, color: '#fff' }}> Emit Beam </Text>
      </TouchableOpacity>
    </View>
  );
}

Then yarn android to run it. The scanner beam will emit when you press the button which shows that in principle this should work.

@mindaugasnakrosis
Copy link
Author

Thanks for a quick answer, looks like initialising expo with bare project type fixes the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants