push notification using APN

Please provide the following:

  1. SDK Version:46.0.16
  2. Platforms(Android/iOS/web/all):IOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on. expo-notification

Hi i am trying to send Push notification in Android and IOS,
for android i am able to send using code in apk or aab working fine.

But in IOS how i can able to send the push notification.
for ios code in docment it was given below.
const jwt = require(“jsonwebtoken”);
const authorizationToken = jwt.sign(
{
iss: “xxxxxxx”,
iat: Math.round(new Date().getTime() / 1000),
},
fs.readFileSync(“./xxxxxxx.p8”, “utf8”),{
header: {
alg: “ES256”,
kid: “xxxxxxx”,
},
}
);
const http2 = require(‘http2’);
const IS_PRODUCTION = false;
const client = http2.connect(
IS_PRODUCTION ? ‘https://api.push.apple.com’ : ‘https://api.sandbox.push.apple.com
);

const request = client.request({
':method': 'POST',
':scheme': 'https',
'apns-topic': 'test app',
':path': '/3/device/' + token, // This is the native device token you grabbed client-side
authorization: `bearer ${authorizationToken}`, // This is the JSON web token we generated in the "Authorization" step above
});
request.setEncoding('utf8');

request.write(
JSON.stringify({
aps: {
  alert: {
    title: "📧 You've got mail!",
    body: 'Hello world! 🌐',
  },
},
experienceId: 'username/slug', // Required when testing in the Expo Go app
scopeKey: 'username/slug', // Required when testing in the Expo Go app
})
);
request.end();

require(“jsonwebtoken”), require(“http2”); are node js imports. how do we use in expo react native?
can some give example code for this. i am using getDevicePushTokenAsync().data to get the token, not getExpoPushTokenAsync().data
we are fallowed this document Sending Notifications with APNs & FCM - Expo Documentation

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.