آموزش جاوااسکریپت انجمن ها react native خطا در push notification

  • این موضوع 3 پاسخ، 2 کاربر را دارد و آخرین بار در 4 سال، 9 ماه پیش بدست مهدی به‌روزرسانی شده است.
در حال نمایش 4 نوشته (از کل 4)
  • نویسنده
    نوشته‌ها
  • #17322 پاسخ
    arash
    مشارکت کننده

    سلام
    من پروژه نوتیفیکیشن رو نوشتم طبق آموزش اما وقتی روی send notification کلیک کردم خطای زیر رو نشون میده
    Undefined is not a function(evaluating ‘_reactNativePushNotification2.default.localNtotifacation’)b
    sendNotification
    D:\project react native \notification\App.js:37,:38
    و فایل app.js به صورت زیر هست:
    import React, { Component } from ‘react’;
    import PushController from ‘./PushController’;
    import PushNotification from ‘react-native-push-notification’;
    import PushNotificationAndroid from ‘react-native-push-notification’;
    import {
    Platform,
    StyleSheet,
    Text,
    View,
    Button,
    AppState,
    DeviceEventEmitter
    } from ‘react-native’;

    export default class App extends Component<Props> {
    constructor(props){
    super(props);
    this.handleAppStateChange = this.handleAppStateChange.bind(this);
    this.sendNotification = this.sendNotification.bind(this);
    }
    componentDidMount(){
    AppState.addEventListener(‘change’,this.handleAppStateChange);
    }
    componentWillUnMount(){
    AppState.removeEventListener(‘change’,this.handleAppStateChange);
    }
    handleAppStateChange(appState){
    if(appState===’background’){
    PushNotification.localNotificaionSchedule({
    message:’Sheduled notification delay message’,
    date:new Date(Date.now()+(2000))
    })
    }
    }

    sendNotification(){
    PushNotification.localNotificaion({
    message:’you pushed the notification button’,
    title:’my notification title’,
    ongoing:true,
    vibrate:true,
    playSound:true,
    actions:'[“YES”,”NO”]’,
    color:’red’
    })
    }

    componentWillMount(){
    PushNotificationAndroid.registerNotificationActions([‘yes’,’no’]);
    DeviceEventEmitter.addListener(‘notification ActionReciever’,
    function(e){
    console.log(‘notification ActionReciever’+e);
    const info = JSON.parse(e.dataJSON);
    if(info.action==’YES’){
    alert(‘accept’);
    }
    else if(info.action==’NO’){
    alert(‘reject’);
    }
    }
    )
    }
    render() {
    return (
    <View style={styles.container}>
    <Button title=”send notification”
    onPress={this.sendNotification}/>
    </View>
    );
    }
    }

    const styles = StyleSheet.create({
    container: {
    flex: 1,
    justifyContent: ‘center’,
    alignItems: ‘center’,
    backgroundColor: ‘#F5FCFF’,
    },
    });
    لطفاً راهنمایی فرمایید.
    با تشکر

    #17344 پاسخ
    مهدی
    میهمان

    سلام.
    به احتمال زیاد در لینک کتابخانه مشکل وجود داره.link رو به صورت دستی انجام بدید و حتما از دستور react-native run-androiud بعد از نصب استفاده کنید

    #17376 پاسخ
    arash
    مشارکت کننده

    سلام
    react-native link رو زدم اما بازم همون خطای قبلی رو میده .
    react-native run-android رو که حتما میزنم برای اجرا تو دیوایس واقعی.

    #17396 پاسخ
    مهدی
    میهمان

    سلام.از راهنمای کتابخانه استفاده کنید و به صورت دستی لینک کنید

در حال نمایش 4 نوشته (از کل 4)
پاسخ به: خطا در push notification
اطلاعات شما: