Expo Notification error

I receive this error when I click the notification

Hey @samassango!

I’m really sorry you’re encountering this issue, must be annoying.

Could you please give me some more information about your Expo app? What SDK version are you on? Are you detached? Do you have any code examples?

In addition, if you upgraded Expo SDK for your current project, could you let me know whether or not you were aware of the breaking changes? I can help you find those if you need help.

Look forward to hearing back from you!

Hey @jimmylee

I am currently using the following
react version ^16.0.0-alpha.12
react-native version 0.47.0
expo version 20.0.0

I was using
expo 15.0.0 and upgraded to 20.0.0

example where notification it’s implemented
root App.js

`import React, { Component } from ‘react’;
import { Platform } from ‘react-native’;
import AppNavigator from ‘./AppNavigator’;
import { createTBLLogin, createTBLHistory} from ‘./utils/sqliteHelper’;
import Expo, { Notifications, SQLite } from ‘expo’;
import { registerForPushNotificationsAsync } from ‘./utils/firebaseConfig’;
import { Actions } from ‘react-native-router-flux’;
export const sqLiteDataSorce = SQLite.openDatabase(‘tshwaneMobi.db’);
class App extends Component {
componentWillMount(){
createTBLLogin(sqLiteDataSorce);
createTBLHistory(sqLiteDataSorce);

    registerForPushNotificationsAsync();
    
    this._notificationSubscription = Notifications.addListener(this._handleNotification);
}

_handleNotification = (notification) => {
console.log(“notific”,notification);
if(notification.origin ===“selected”){
if(notification.data.type === “casehistory”){
Actions.timeline({notificationObject: notification});
}else{
Actions.home({notificationObject: notification})
}
}

};
render() {
return ;
}
}

export default App;
`

`export async function registerForPushNotificationsAsync() {
// Android remote notification permissions are granted during the app
// install, so this will only ask on iOS
let { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);

// Stop here if the user did not grant permissions
if (status !== ‘granted’) {
return;
}
// Get the token that uniquely identifies this device
let token = await Notifications.getExpoPushTokenAsync();

};`

Is there anyway you can try to update your application to the latest SDK to see if it resolves your issues?

hey, did you follow the sdk upgrade instructions for sdk 15 - 20? theres a lot of small changes that most likely caused a small error thats crashing the app.

i also have a demo app with the latest sdk and source code available with notification examples. you can check out the source and see if its helpful

1 Like