Josh
Josh

Reputation: 1062

react-native-push-notification doesn't work on ios DEVICE

I'm using react-native-push-notification, but I have a problem.
With IOS simulator or android emulator, Everything works well.
But with real iphone device, push notification doesn't work. (on release mode or on debug mode, both are not worked.

Here is my setting.

Link binary with Libraries

Set Search Header Path

I check Capabilities/Background Modes/Remote notification on XCODE

And PushNotification.configure

import React from 'react';
import PushNotification from 'react-native-push-notification';

import {
    Auth
} from '../config/router';
import './ReactotronConfig';

export default class App extends React.Component {
    constructor(props) {
        super(props);

        this.PushConfigure();
    }
    PushConfigure() {
        PushNotification.configure({
            onNotification: (notification) => {
                console.log('NOTIFICATION:', JSON.stringify(notification));
            },
            permissions: {
                alert: true,
                badge: true,
                sound: true,
            },
            popInitialNotification: true,
            requestPermissions: true,
        });
    }
    render() {
        return <Auth />;
    }
}

And when I have to push notification

    const date = new Date(Date.now());
    PushNotification.localNotificationSchedule({
        title: '메세지가 도착 했습니다.',
        message: `${data.user._id}: ${data.text}`,
        date,
        actions: 'Yes',
    });

As I said before, notification works well on all simulator (Xcode IOS, android).
But I don't know why notification doesn't work on real IOS device.

If you want more environment or settings on my project, please comment.

Update -

I didn't register on Apple Developer Program.
Is that reason why I can't use notification on real IOS device?

Upvotes: 4

Views: 7865

Answers (2)

chenop
chenop

Reputation: 5143

Since Xcode 11.4 - IOS Simulator should support Push Notification as well

Upvotes: 2

Nisarg Thakkar
Nisarg Thakkar

Reputation: 1547

Yes, I think push notification is not work in iOS simulator so you need to check this in real a device and also check the certificate for push notification is proper while making a release build.

Please also check you get proper device token on onRegister function

PushNotification.configure({
           onRegister: function (token) {
                console.log((token);
            },
            onNotification: (notification) => {
                console.log('NOTIFICATION:', JSON.stringify(notification));
            },
            permissions: {
                alert: true,
                badge: true,
                sound: true,
            },
            popInitialNotification: true,
            requestPermissions: true,
        });

Plese make sure In settings push notification is enabled for your app

Upvotes: 2

Related Questions