im trying to send push by http to Huawei Devices with Huawei consolé integration, but the documentation is confuse, and i'm not really sure how to build my body to send
I have this, but only works for foreground, if the app is in background or terminated, the push isn't working
This is the portar i'm following https://developer.huawei.com/consumer/es/doc/development/quickApp-Guides/quickapp-access-push-kit#dataDesc
{
"validate_only": false,
"message": {
"data": "{title: Hello! 1, description: Hello, shirley!, params: { key1: test1, key2: test2}, ringtone: {vibration: true, breathLight: true}}",
"android": {
"title": "Hello! 1",
"body": "Hello, shirley!",
"params": {
"key1": "test1",
"key2": "test2"
},
"click_action": {
"type": 3
}
},
"token": [
"IAAAAACy0irbAADqfnlY9pfEgoWWoIzgCBXQzPol8CTNzV6i3V5byP7cIhuU74vovAwysjkI_XMwowYj1sv5SrhXRi-sYXB5OrplLHEB02LO0pKHcA"
]
}
}
The conditions received by the Push notification do not need to be run in the foreground.
According to the Docs,You can send push messages in either of the following ways:
Select target users in AppGallery Connect. In this case, messages can be pushed to both quick apps on the live network and those running on a quick app loader.
Send push messages to a large number of users in batches by invoking server APIs. In this case, messages can be pushed to both quick apps on the live network and those running on a quick app loader.
Conditions for a quick app to receive push messages are as follows.
Related
I am trying to send notifications to both Android and iOS devices using FCM. The front end was coded with Flutter. I am working with Typescript/NestJS at the back end. For some reason, iOS devices receive all the notifications with a push notification/pop-up but Android devices sometimes don't. Strangely, the notifications ALL arrive at the test device INBOXES. It's just that sometimes, Android devices do not show a pop-up/push notification.
Targeting users thru a Firebase topic works as expected: push notifications do arrive for Android and iOS. I do have to find and filter out the users to target before sending the target device IDs to FCM. I am confident my filters are correct. The notifications arrive in the app inbox for both Android and iOS after my filtering. Also, changing the device ID/token in my database causes an error from FCM:
{"code":"messaging/registration-token-not-registered","message":"Requested entity was not found."}
If I revert the data to its original values, the app runs fine. I've checked and compared the data I pass to Node.js' FCM module and it looks fine. Here, messaging is an instance of firebaseAdmin.messaging().
param = {
"android": {
"data": {
"id": "67bcd478-f643-4c9e-848a-be354a6b85d4",
"icon": "default",
"title": "Test",
"body": "Direct From Playground"
}
},
"apns": {
"payload": {
"aps": {
"id": "67bcd478-f643-4c9e-848a-be354a6b85d4",
"icon": "default",
"title": "Announcements",
"body": "Direct From Playground",
"alert": {
"title": "Announcements",
"body": "Direct From Playground"
}
}
}
}
}
messaging.sendMulticast({
tokens: value as string[],
...param,
});
Again, the code above sometimes successfully triggers push/pop-up notifications on Android devices but ALWAYS on iOS. Could this be a problem for the front-end handling of my data? Am I missing some parameters?
I'm trying to get push notifications running with React Native on iOS and Android.
To do so I am using firebase, as that seemed to be very convenient.
On Android I managed to show notifications when the app is in the foreground and at least show a log when the app is in the background, meaning I can process them.
On iOS I have not managed to do any of those, not from our custom backend in aws (via SNS), nor from firebase console with fcm token. What interestingly worked, was to show a badge on the ios app icon when sending broadcast messages to all users. So something seems to be received on the phone.
Now looking into this a little deeper I found that iOS needs notifications in the following format:
{
"Simulator Target Bundle": "com.compass.SomeExampleApp",
"aps": {
"badge": 0,
"alert": {
"title": "Push Notification Test",
"subtitle": "Hey! 👋",
"body": "Is this working?",
},
"sound":"default"
}
}
At least this is how you can test them on the sim.
1. Does it mean that I have to send the notifications in that same format? Or can it be something like:
{
"data":{},
"apns": {
"Simulator Target Bundle": "com.company.Example",
"aps": {
"alert": {
"body": "Wellcome to MyApp!",
"title": "MyApp"
}
}
}}
2. How can I send a format that iOS AND Android can read, show on screen and process in background if necessary?
Since we are sending only data messages I think this might be part of the issue, if I look at our backend.
Still when sending from firebase I am not able to show anything on screen on ios Device. Any hint?
I found a solution that actually works on both platforms although it is a bit weird since it seems to be outdated. Code needs to look like this to send to both iOS and Android:
{ "GCM": "{ \"notification\" : {\"content_available\" : true }, \"data\": { \"body\": \"Sample message for iOS endpoints\", \"title\":\"Hello world\"} }" }
As seen here APNS attributes seem to at least partly work if added within the GCM message like content_available in this case or badge.
I am using the react-native-push-notification package and PubNub push notifications to handle the remote notifications. This all works on iOS just fine and I'm getting the notification data coming in from the onNotification method on android but there is no actual notification popping up on the screen as I would expect. Am I missing a configuration on the FCM side maybe or a specific permission check I need to ask for to make sure remote notifications can be shown on android devices?
I've followed the manual steps on the react-native-push-notification package to a T and triple checked I didn't miss something
This GCM bit I was passing to Pubnub was this
"pn_gcm": {
"data": {
"title_for_mobile": "George Washingtons's phone has moved outside of the group",
"summary_for_mobile": [ "George Washingtons's phone has moved outside of the group" ],
"data": {
"action": "radiusTrigger",
"userId": 6,
"groupId": 8
}
}
}
and the title_for_mobile wasn't sending it to my phone as a push notification so I had to change it to
"pn_gcm": {
"data": {
"message": "George Washingtons's phone has moved outside of the group",
"data": {
"action": "radiusTrigger",
"userId": 6,
"groupId": 8
}
}
}
And now it shows the notification on android
I'm trying to send a payload using GCM that can be handled on the background or foreground by clients using Android and iOS. The messages are delivered to clients using both platforms that are subscribed in a topic.
Because I need the iOS app to handle the data even when the app is on the background or closed, I'm setting "content_available": true, which works as expected on iOS.
However, when I add that parameter, Android does not handle the received data and instead displays a blank notification.
Here's an example payload:
{
"to": "/topics/946",
"content_available": true,
"data": {
"time": "2016-02-04 18:33:08",
"message": "Hello",
"msgType": "chat",
"senderId": "50",
"senderName": "John"
}
}
The documentation says that data messages should wake the Android app anyway:
On iOS, use this field to represent content-available in the APNS
payload. When a notification or message is sent and this is set to
true, an inactive client app is awoken. On Android, data messages wake
the app by default. On Chrome, currently not supported.
What am I doing wrong?
EDIT: I've already tried using "priority":"high", which does not make any difference.
I have just started developing an app for Android and iPhone with trigger.io and parse.com. Now I'm stuck trying to add push notifications to the app. I send test pushes from the control panel at parse.com but nothing happens on the Android phone I'm testing with.
Here's what I've done:
Added the partners/parse section in config.json with applicationId and clientKey from the settings at parse.com
Added "event": true to the modules section in config.json
My config.json looks like this:
{
"config_version": "2",
"name": "My test app",
"author": "(my email)",
"version": "0.1",
"platform_version": "v1.4",
"description": "An empty app created by default",
"modules": {
"logging": {
"level": "DEBUG"
},
"event": true,
"geolocation": true,
"contact": true,
"file": true,
"is": true,
"media": true,
"notification": true,
"prefs": true,
"request": {
"permissions": ["http://*/*", "https://*/*"]
},
"tools": true,
"reload": true
},
"partners": {
"parse": {
"applicationId": "(my real app id)",
"clientKey": "(my real client key)"
}
}
}
Added the following code to listen for incoming pushes:
forge.logging.info('Adding push listener');
forge.event.messagePushed.addListener(function (msg) {
forge.logging.info('Got push: ');
forge.logging.info(JSON.stringify(msg));
}, function(err) {
forge.logging.error('There was an error receiving push!');
forge.logging.error(err);
});
To test the app I connect my Android phone by USB cable to my Mac and choose "Run android" in Trigger toolkit in the browser
In the log I see the messages "Initializing Parse and subscribing to default channel" and "Adding push listener"
I go to parse.com Push notifications and see that there is one connected device. I test to send several messages, some in "Message" mode, some in JSON mode.
Parse thinks that the messages get sent but nothing is logged on my side
I also tested connecting another Android phone. Parse then indicated that there were two reachable phones, but the new phone didn't get any messages either.
Looking at the documentation and examples I can't think of anything else to try. I cannot decide if this is a trigger.io problem or a parse.com problem.
Does anyone have any ideas?
Is this a problem just when you're using the default broadcast - rather than a named - channel?
We have a fix for a problem with the broadcast channel on Android ready to be deployed tomorrow or early next week - it will be in platform version v1.4.27.