I am implemented APN (apple push notification) it is getting success. I am getting result
Blockquote
[1] => Pushok\Response Object
(
[apnsId:Pushok\Response:private] => XXXXXXXXXXXXXXXXXXXXX
[deviceToken:Pushok\Response:private] => XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[statusCode:Pushok\Response:private] => 200
[errorReason:Pushok\Response:private] =>
[error410Timestamp:Pushok\Response:private] =>
)
but in the app, I am not able to receive any notifications in the app. The app is built in expo react native. I am using an expo-notification package and using the getDevicePushTokenAsync() function.
Related
I have tried to follow this guide https://rnfirebase.io/messaging/usage/ios-setup to set up push notifications for my React-Native application. In particular, I have done the following:
Adding Push Notification & Background Mode capabilities(with Remote fetch and background activities)
Register a key(with APNs enabled) in Apple developer account and upload it to firebase console settings with the correct KeyID(obtained when registering the key) and TeamID(obtained from developer's membership detail)
Register the App Identifier(with APNs capability). Since there are two bundle Identifiers for my project - org.reactjs.native.example.AppName and org.test.AppName, I have tried both but none works.
Register a Provisioning profile. I believe this wil automatically sync with my Xcode.
I note that I can further configure the APNs capability after registering the App Identifier, but this is not mentioned in the guide and I didn't do that:
To configure push notifications for this App ID, a Client SSL Certificate that allows your notification server to connect to the Apple Push Notification Service is required. Each App ID requires its own Client SSL Certificate. Manage and generate your certificates below.
In my React-Native application, I have the following code:
const App => {
useEffect(() => {
async function requestUserPermission() {
const authStatus = await messaging().requestPermission();
const enabled =
authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
authStatus === messaging.AuthorizationStatus.PROVISIONAL;
if (enabled) {
console.log('Authorization status:', authStatus);
}
}
requestPermission();
});
useEffect(() => {
async function getToken() {
await messaging().registerDeviceForRemoteMessages();
const token = await messaging().getToken();
console.log(token);
}
getToken();
});
...
}
After accepting the notification permission request when the app launch. This will output the FCMs token, which I use to send a test message in the Firebase console.
Did I miss any steps? Is it possible to send push notifications in React-Native debug built running under metro in the first place? Thank you in advance.
I figured out the problem. It is because I used a different bundle ID when building the product in XCode and when registering the identifier in Apple Developer Account. The steps by steps does work as of writing.
Hi I am using Onesignal for my application to send push notifications to my application, I am able to send the push notification and getting to my app, when i click on notification nothing is happening it is just disappearing, How can i open the application and after login to application i need to got to notifications screen, Is there anything i need to configure in onesignal and my native code. As of now i have done for android. Below is the code.
In app.js:
useEffect(() => {
OneSignal.setAppId("myAppId");
OneSignal.setNotificationOpenedHandler((notification) => {
console.log("OneSignal: notification opened:", notification);
});
}, []);
In build.gradle:
implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
I've made an app using react native firebase 5.6.0. I'm getting notifications from firebase and displaying them with this piece of code:
this.notificationListener = firebase
.notifications()
.onNotification((notification: Notification) => {
notification.android
.setChannelId('channel')
.android.setSmallIcon('ic_launcher')
.android.setPriority(firebase.notifications.Android.Priority.Max)
.android.setColor('#121243');
firebase.notifications().displayNotification(notification);
});
The problem is push notifications showing even when the app is on foreground and running. I want them to only show when the app is on background.
I've solved the problem using AppState
this.notificationListener = firebase
.notifications()
.onNotification((notification: Notification) => {
if (AppState.currentState != 'active') {
notification.android
.setChannelId('channel')
.android.setSmallIcon('ic_launcher')
.android.setPriority(firebase.notifications.Android.Priority.Max)
.android.setColor('#121243');
firebase.notifications().displayNotification(notification);
}
});
So if the app is in active state the notification won't show.
Currently trying to open whatsapp from my React Native app with Expo. I have the code below:
let url = 'whatsapp://app';
Linking.openURL(url).then((data) => {
console.log('WhatsApp Opened');
}).catch((err) => {
console.log(err);
alert('Make sure Whatsapp installed on your device');
});
The error I get is this:
Error: Could not open URL 'whatsapp://app': No Activity found to handle Intent { act=android.intent.action.VIEW dat=whatsapp://app flg=0x10000000 }
However when I change the url to send, it opens whatsapp fine?
whatsapp://send?phone=3464478983
I am trying to only open whatsapp without a send param
How do I implement SignalR in react native for implementing push notifications?
I have seen implementing SiganlR in react js by using packages like https://github.com/aspnet/SignalR.
I didn't find any solution for implementing signalR in React Native
You can use this package. I am using it right now, it works fine but i have a problem with reconnect hub.start().
You can install with this :
npm install #aspnet/signalr
Example:
let connection = new signalR.HubConnectionBuilder()
.withUrl("/chat")
.build();
connection.on("send", data => {
console.log(data);
});
connection.start()
.then(() => connection.invoke("send", "Hello"));