iOS VoIP push notifications and Firebase - firebase

I'm trying to send VoIP push notifications through the Firebase. I uploaded a *.p8 file to my project in the Firebase Console and now have an APNs Auth Key displayed there.
My alarm push notifications are delivered without any problems:
'apns' => [
'headers' => [
'apns-push-type' => ‘alarm',
],
...
But when I try to change the type to voip I get an error:
'apns' => [
'headers' => [
'apns-push-type' => 'voip',
'apns-topic' => ‘com.mycompany.myapp.voip'
],
...
Firebase response:
#errors: array:1 [
"error" => array:4 [
"code" => 400
"message" => "Request contains an invalid argument."
"status" => "INVALID_ARGUMENT"
"details" => array:2 [
0 => array:2 [
"#type" => "type.googleapis.com/google.firebase.fcm.v1.FcmError"
"errorCode" => "INVALID_ARGUMENT"
]
1 => array:2 [
"#type" => "type.googleapis.com/google.rpc.BadRequest"
"fieldViolations" => array:1 [
0 => array:2 [
"field" => "message.token"
"description" => "Invalid registration token"
]
]
]
]
]
]
Any ideas? Am I missing something important?

The situation at the date (16/03/2020): No, Firebase Cloud Messaging doesn't support APNS VoIP push notifications, but it's planned.
The official Firebase support answer:
Currently, VoIP push is not supported by FCM. However, we're aware that a lot of developers like you want this, so there's already a feature request filed for this. As of now, we are yet to find out any details or timelines as to when it will be implemented. You can check our release notes from time to time for any updates about Firebase features and its services.

Related

Token XRPL listing

I am trying to list a token of XRPL, set truct and receive the following
"error_message" => "Field 'tx_json.LimitAmount' has invalid data."
"request" => array:5 [▼
"command" => "submit"
"fee_mult_max" => 1000
"offline" => false
"secret" => "<masked>"
"tx_json" => array:6 [▼
"Account" => "rX49UBNi94tCCt2jb7tHVjdYSVwHNhQK2"
"DestinationTag" => 1
"Fee" => "15000"
"Flags" => 262144
"LimitAmount" => array:3 [▼
"currency" => "Xoge"
"issuer" => "rJMtvf5B3GbuFMrqybh5wYVXEH4QE8VyU1"
"value" => "1000000000000000"
]
"TransactionType" => "TrustSet"
]
]
"status" => "error"
using this document: https://xrpl.org/trustset.html
XRP Ledger supports either a three-letter ISO 4217 Currency Code or a 160-bit(40-character) hexadecimal string as value for "currency" field.
In your case(above code), you are using "Xoge" as value for the field "currency" inside "LimitAmount" object. "Xoge" has more than 3 letters, so it's throwing error. You can either switch to a 3 letter currency code or convert "Xoge" into 160-bit(40-character) hexadecimal string.
LimitAmount: {
currency: '586F676500000000000000000000000000000000',
issuer: 'rJMtvf5B3GbuFMrqybh5wYVXEH4QE8VyU1',
value: '1000000000000000'
},
Here 586F676500000000000000000000000000000000 represents Xoge in 160-bit hex.
Couple of more things I noticed from your code:
Fee is represented in drops. So you can lower your fee a bit, and it'll still work.
You are setting flag 262144 which enables rippling. Usually TrustLine is setup by regular users with the issuer, so it's always recommended to have flag 131072, which blocks rippling from the user end of the TrustLine.

Using multiple firewalls and multiple guards

I've got a Symfony 5.1 (fullstack) application and I'm using Api Platform. Now I want to use API tokens to access the API (using Custom Authentication System with Guard), but already logged in users should be able to access the API without a token.
I've used the example from the Symfony documentation about Multiple Guard Authenticators and added a second authenticator:
$container->loadFromExtension('security', [
// ...
'firewalls' => [
'api' => [
'context' => 'my_context',
'pattern' => '^/api',
'guard' => [
'entry_point' => LoginFormAuthenticator::class,
'authenticators' => [
LoginFormAuthenticator::class,
ApiTokenAuthenticator::class,
],
],
],
'default' => [
'context' => 'my_context',
'anonymous' => true,
'lazy' => true,
'guard' => [
'authenticators' => [
LoginFormAuthenticator::class,
],
],
],
],
);
When I use TokenAuthenticator as the entry_point, requests to ^/api/ are not accessible by logged in users. They'll get a 401 Unauthorized ("A Token was not found in the TokenStorage.").
When I use ApiTokenAuthenticator as the entry_point, (XMLHttp-)requests to ^/api/ are redirected to /login instead of a 401 Unauthorized.
How can I have API endpoints that are accessible by both authenticators?
Edit: Thanks to Cerad, I've added context to both firewalls, as described here. Didn't make any difference.

iOS application closes with no error when trying to retrieve push message data attribute

I'am sending push messages to application with react-native-firebase and it look's wonderful ! Also, I need to receive some portion of data, so sending data something like this
$request_body = [
'to' => $TOKEN_ID,
'notification' => [
'title' => 'Title',
'body' => 'Body',
'sound' => 'default',
],
'data' => [
'key' => 'value',
],
];
I'am trying to listen open push message event as bellow
this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
const notification = notificationOpen.notification;
const data = notificationOpen.data;
setTimeout(() => {
Alert.alert(data.key);
}, 5000);
});
After 5 second left, application closes without any error message. If changing Alert.alert(data.key); with Alert.alert(notification.title); application work`s fine and show an alert. Can someone explain to me, why retrieving data is not work properly?
After some research, I found a solution
const data = notification.data;
or
const data = notificationOpen.notification.data;

DynamoDB UpdateItem with ReturnValues parameter returns nothing on failed ConditionExpression

Using aws/aws-sdk-php 3.21.6. I must be misunderstanding how ReturnValues works when a ConditionExpression meets the ConditionalCheckFailedException error.
What I'm hoping is that if the ConditionExpression fails, which in turn triggers the ConditionalCheckFailedException, that I can catch this exception and then get access via ReturnValues to the new Attributes from DD.
The docs Attributes I'm expecting from ReturnValues seem to imply this.
From testing, however, ReturnValues only returns Attributes if the ConditionExpression is true, not when it fails.
$response = $client->updateItem([
'TableName' => 'MyTable',
'Key' => [
'customer_url' => [
'S' => 'someurl.com'
],
'customer_platform' => [
'S' => 'some_platform'
]
],
'ExpressionAttributeNames' => [
'#C' => 'createdAt'
],
'ExpressionAttributeValues' => [
':val1' => [
'S' => '2017-01-24T14:15:32'
],
':val2' => [
'S' => '2017-01-24T14:15:30'
]
],
'UpdateExpression' => 'set #C = :val1',
'ConditionExpression' => '#C = :val2', // :val2 originally was 2017-01-24T14:15:30, before attempting to update to 2017-01-24T14:15:32. If I change the field to 2017-01-24T14:15:31, before running this update it will throw the ConditionalCheckFailedException
'ReturnValues' => 'ALL_NEW'
]);
Yes, ReturnValues is populated only if an updateItem succeeds. If it fails, because of ConditionalCheckFailedException or any other reason, ReturnValues will be null.
Supporting documentation from here, with emphasis mine:
Use ReturnValues if you want to get the item attributes as they appeared either before or after they were updated.

AclVoter denies access to 'LIST'

As soon as I set sonata_admin.security.handler to sonata.admin.security.handler.acl the only user who has access is the one with ROLE_SUPER_ADMIN.
I think I configured everything right, obviously not.
I tried:
to give the user the real role ROLE_VIP_CONTACT_ADMIN instead of assigning by a fos_group, no success.
all options forsecurity.access_decision_manager.strategy: affirmative, consensus and unanimous
to delete all acl tables, acl:init, sonata:admin:setup-acl, with and without sonata:admin:generate-object-acl and cleared the cache every time.
With no success.
# Acme\MyBundle\Controller\CRUDController.php
$securityContext->getAdminPermissions();
# -> ["CREATE", "LIST", "DELETE", "UNDELETE", "EXPORT", "OPERATOR", "MASTER"]
dump($this->admin->getSecurityInformation());
/* -> array:3 [▼
"GUEST" => array:2 [▼
0 => "VIEW"
1 => "LIST"
]
"STAFF" => array:3 [▼
0 => "EDIT"
1 => "LIST"
2 => "CREATE"
]
"ADMIN" => array:3 [▼
0 => "MASTER"
1 => "OPERATOR"
2 => "EXPORT"
]
] */
dump($this->getUser()->getRoles());
/* -> array:15 [▼
0 => "ROLE_ADMIN"
1 => "ROLE_VIP_CONTACT_GUEST"
2 => "ROLE_VIP_CONTACT_STAFF"
3 => "ROLE_VIP_CONTACT_ADMIN" # <--- I gave him everything!
[...]
9 => "ROLE_ALLOWED_TO_SWITCH"
[...]
16 => "ROLE_USER"
] */
Now I open my browser and go to app_dev.php/my-path-to/vip/contact/list, resulting in an AccessDeniedException.
/edit: It's the same problem as here ACL + SonataAdminBundle + SonataUserBundle.
On Symphony >3.1 you should use this:
services:
security.acl.permission.map:
class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap
instead
parameters:
security.acl.permission.map.class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap
After hours of debugging, the result is to let ACL know about the LIST permission by using Sonata's AdminPermissionMap.
See SonataAdminBundle 5. Security and Documentation » Admin (Ctrl+F: security.acl.permission.map.class)
parameters:
security.acl.permission.map.class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap
You might already know this.
To make a long story short: Configuration is not only done by writing some config files, but also to import the right ones.

Resources