Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification background disappears couple seconds after notification #12

Open
zoozalp opened this issue Aug 8, 2018 · 0 comments
Open

Comments

@zoozalp
Copy link

zoozalp commented Aug 8, 2018

In the following code, white background stays in view for couple seconds after notification disappears. I've seen this in Android but not tested on iOS yet.

Is it a bug or am I missing something?

`import React from "react";
import {View, Platform, PushNotificationIOS, StyleSheet} from "react-native";
import Notification from "react-native-in-app-notification";

const defaultIcon = require("../assets/defaultImages/logo_small.png");

export class InAppNotification extends React.Component {

handleRegister = token => {
    console.log('push token', token);
};

handleNotification = notification => {
    console.log("notification", notification);
    const message = Platform.OS === "ios" ? notification._alert : notification;
    if (!message) {
        console.log("Empty message.");
    } else {
        console.log("message", message);
        if (!this.notification) {
            console.log("In app notification ref is not set yet.");
        } else {
            this.notification.show({
                icon: defaultIcon,
                title: message.title,
                message: message.body
                // onPress: () => Alert.alert('Alert', 'You clicked the notification!'),
            });
        }
    }

    // required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
    if (Platform.OS === "ios") {
        notification.finish(PushNotificationIOS.FetchResult.NoData);
    }
};

componentDidMount() {
    const {pushNotification: PushNotification} = this.props;
    PushNotification.onNotification(this.handleNotification);
    PushNotification.onRegister(this.handleRegister);
}

render() {
    return (
        <View style={styles.root}>
            <Notification ref={ref => {this.notification = ref;}}/>
        </View>
    )
}

}

const styles = {
root: {
position: "absolute",
top: 0,
left: 0,
right: 0,
height: 200,
elevation: 999,
zIndex: 999
}
};`

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

No branches or pull requests

1 participant