Closed vishalgadhiya91 closed 6 years ago
Hi @vishalgadhiya91. I'm sorry you can't get your example code to work. This tracker is for bugs with the library, not support using the library. That being said I did quickly review your example and it looks like you are using the iOS example code for icons which may be causing problems.
I suggest you review the README first and if that doesn't answer your question try posting it to a service like StackOverflow to see if someone there can help you with your project. Good luck!
Thanks for replay.
Hi,
I have implement this code in my test project in "app.js", but it will not work. Any quick option or menu can't display. I have tested in android real device (7.1) Please check my below code and respond me.
import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View, Alert, DeviceEventEmitter } from 'react-native';
var QuickActions = require('react-native-quick-actions');
const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu', });
type Props = {};
QuickActions.setShortcutItems([ { type: "Orders", // Required title: "See your orders", // Optional, if empty,
userInfo: {
url: "https://png.icons8.com/metro/1600/email.png" // provide custom data, like in-app url you want to open
}
}
]);
type
will be used instead subtitle: "See orders you've made", icon: "Compose", // Pass any of UIApplicationShortcutIconTypeQuickActions.isSupported(function(error, supported) { if (!supported) { console.log("Device does not support 3D Touch or 3D Touch is disabled."); } });
export default class App extends Component {
constructor(props){ super(props)
} componentDidMount(){ let self = this; QuickActions.popInitialAction() .then(function(data) { if (data == null) return; self.setState({ quickAction: data }); console.log("popInitialAction", data); Alert.alert(data.toString()); }) .catch(console.error);
}
componentWillUnmount() { DeviceEventEmitter.removeListener( "quickActionShortcut", this.handleQuickAction ); }
}
render() { const { quickAction } = this.state;
}
// Clear them all //QuickActions.clearShortcutItems(); }
const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, }); `