chore: rename package
This commit is contained in:
+3832
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "firebase-messaging-scripts",
|
||||
"description": "Used to demonstrate sending a RemoteMessage to a client.",
|
||||
"scripts": {
|
||||
"send-message": "node send-message.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase-admin": "^11.0.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
//
|
||||
var admin = require('firebase-admin');
|
||||
// 1. Download a service account key (JSON file) from your Firebase console and add to the example/scripts directory
|
||||
var serviceAccount = require('./wyatt-notification-example-firebase-adminsdk-aji7z-d74c5eb58d.json');
|
||||
admin.initializeApp({
|
||||
credential: admin.credential.cert(serviceAccount),
|
||||
});
|
||||
|
||||
// 2. Copy the token for your device that is printed in the console on app start (`flutter run`) for the FirebaseMessaging example
|
||||
const token = 'd3gPMU4qfEXLtWuOt0yigw:APA91bF-q1Y36Lz-eb9JrKPR6A7QJHXdwSFN5CN18m3YUQJDD3Km57HWvCjQRFAjA-0vUM507bXQkD4sjI_YmsKyGJsepwViat_ik4_1ra0rh2dv3GVxW9QRr84R_COMG5339IQ3Qitw';
|
||||
|
||||
|
||||
// 3. From your terminal, root to example/scripts directory & run `npm install`.
|
||||
// 4. Run `npm run send-message` in the example/scripts directory and your app will receive messages in any state; foreground, background, terminated.
|
||||
// If you find your messages have stopped arriving, it is extremely likely they are being throttled by the platform. iOS in particular
|
||||
// are aggressive with their throttling policy.
|
||||
admin
|
||||
.messaging()
|
||||
.sendToDevice(
|
||||
[token],
|
||||
{
|
||||
data: {
|
||||
foo:'bar',
|
||||
},
|
||||
notification: {
|
||||
title: 'A great title',
|
||||
body: 'Great content',
|
||||
},
|
||||
},
|
||||
{
|
||||
// Required for background/terminated app state messages on iOS
|
||||
contentAvailable: true,
|
||||
// Required for background/terminated app state messages on Android
|
||||
priority: 'high',
|
||||
}
|
||||
)
|
||||
.then((res) => {
|
||||
if (res.failureCount) {
|
||||
console.log('Failed', res.results[0].error);
|
||||
} else {
|
||||
console.log('Success');
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Error:', err);
|
||||
});
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "wyatt-notification-example",
|
||||
"private_key_id": "d74c5eb58d43805986a1eadfab77951e9fd9b7a4",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC6EjAUdxDTF3dB\nmkdIE/RlyHEzKYekWj9s8qGxhz9u4X2betC3doxrQSrFNsVgg1pbAXReyvBQyHz6\nyC1rdMQDUCE6IgM1WjlnOJOhKvf4OJExtr2kwy4LTjYg/UJI32lOwpaL8CE5JJ+J\n94cqyNpRuoL1rFMzP4zReeeKVKnroWUTxTLR3wskOBCuEvlmMHjxTB2kJnkuaLLz\nG32gCuO4yPxUo0itVLGAk0a17lZMQ5glt+VSGk9w8S9ixDIs53Uj2pjj6ip4bjmb\n3tMiE5GnLWJFLafqA5JoprPAgCAz0f69LKZFjxAev335ogMCl5UcWG7qeU76Iw3b\nsKbtJsFTAgMBAAECggEAOCHFfF8A5dVl5hX/G/jdGRlzQM5t+4A4MwstCSu2UKJY\nrJ9LuJTcPnzdxLnFqFxn1R1muDP7dDtPLK5XuVtzyFYTeACLvDwYJhH0w0F9pdWW\nw4sPwdUZnlJ9VM1iAi7Xi2l7VgLeWuk38byI+7i018PuvuM6BDNPLWBbn6jzy7+T\nvCVcv9iTM3nyGb+Lx4oFzget+orJazGUjwfcHLAS+Lft2o7CN+y3V3UrAadoKX7J\nbY6fs9aT0rRIfLCd54cz3HZH9MwPbTs/VC4jDbbF2yI8x6IzfXSFpodkIweF/Itl\n3uE4FwigVMKbPd5rU95jliy/jftdDEZrw8hcBXN3MQKBgQDwcbVc4HBS6P4mG8go\ne5nbiZO7UnEjdyMjopu0fJt8nWIt+bF3dzE/YeyF7PpON5neGjodO1beiXLVnnV3\n0Auqy/sxzeuv/25H56FBQIWOtnU1qGvJbbohape6jKKnOB++5ROg77i6PAqsWB2j\nsMwq+HMKJkI2dD8ld5bLEMj0cQKBgQDGG/BsflxWqcDihyKY8EMrc1DfejHz2CKf\nC6i4hlcshHLBtgyko9vws+3UDF1dPQSWhBgCQsxGvxsFAyBRq+otfrJ43qofOF8D\nCwxbEK7wV0O458tqxLiahjtToUxK+DH4BxZFCFf41QBFLzYbyfYMZEJXkaH0H2wK\nzkPNRSwkAwKBgQCwgtkgUIdE5lREx5pd1bbySoIQPwpdfcVnEKV7jwpaJfOAStB0\nIiUeIZYQDxMFvp2PRfOpp/kyrvaFSal0hl86SDqkqkW+UyazVKC1lVc2mE1dUcGn\nAo1koKq4QSva1EHB0sthFvqmhRNUx+8iTtTjKrbRGZr7/MSqjas+cZkEkQKBgA9p\n3xPh5PdNL9ewIe36S4+W4kTw8fAB8fej5ZWtxhyNlYwiyOsKYLNinG9yItV9SN0Z\nG/EZF2GtvsFuE9am5IpzoBktYdkZ/rJy6pwvOR0z/O3nAvmkoqRLK1R/aTswAltE\n2eO3GXkfwWyglrokxYMDTfIYP5yJ0VMp5zaSWjPXAoGADuWdXwtVLJgLPz/XXXi1\nQC33xUQ1YOSTxL7eYvHsxqxnQGgZ9E3w4ciHpnS4//Tjin1U8ElmKQ9TrZqvOA2+\n9lqBPskwzvc8bh6dfVf1K8vOKUk4cOP/aPFFGT1k0THJhvC2FG7FGWfS9AEXRN3I\nNlnLpWR48wtq0Yom9X+S0io=\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "firebase-adminsdk-aji7z@wyatt-notification-example.iam.gserviceaccount.com",
|
||||
"client_id": "104485519296221532664",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-aji7z%40wyatt-notification-example.iam.gserviceaccount.com"
|
||||
}
|
||||
Reference in New Issue
Block a user