How to set badge with FCM v1 http api - firebase

I have a react-native application using Firebase to handle push notifications. I always used FCM legacy api to send the notifications.
I recently switched to the new FCM v1 API. After changing authentification mode and payload structure, everything is working well, except the badge count on the app. I checked the documentation at https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages, there is a notification_countfield for Android, but nothing for iOS. With the legacy api, I was able to define a badge property.
Here is my current structure :
'message' => [
// Android
'android' => [
'priority' => 'HIGH',
'notification' => [
'notification_count' => $badge
]
],
// iOS
'apns' => [
'payload' => [
'aps' => [
'notification_count' => $badge
]
]
],
'token' => $deviceToken,
'notification' => [
'title' => $title,
'body' => $body
],
'data' => [
'title' => $title,
'message' => $body
],
'fcm_options' => [
'analytics_label' => $analyticsLabel
]
]
Thanks in advance for your help

The solution was finally to replace notification_count by badge under 'apns' => 'payload' => 'aps'

Related

Dynamic query string params in Wordpress Rest API

I cant find any information in the Wordpress rest api documentation about how to pass in a dynamic string as part of a url, I know how to do an ID.
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<type>)', [
'args' => [
'type' => [
'description' => __('Type of notification to generate', $this->pluginName),
'type' => 'string',
'enum' => ['product_question']
]
],
[
'methods' => \WP_REST_Server::CREATABLE,
'callback' => [$this, 'create_item'],
'permission_callback' => [$this, 'create_item_permissions_check'],
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
],
'schema' => [$this, 'get_public_item_schema']
]);
The above is the code im using to try and register the route. The route should look something like this /notifications/product_question The last part of the url, would be the dynamic part, and would be one of an array of values

ErrorException Undefined property: Illuminate\Auth\SessionGuard::$id

I have create admin in laravel. so now i want to post as a admin to database but when i did i got error like above.
i have a Post Table, I have admin id, I have admin table but it couldn't work.
// To create post
$post = new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post->admin_id = Auth()->guard('admin')->id;
$post->save();
I did like this above but i got error.
I also tried as
$post->admin_id = Auth()->admin()->id;
i got admin() not found.
I did Everything as per instructions but i got error.
$post->user_id = Auth()->user()->id;
Whereas this works i don't know what to do. i did everything as per instructions in Github but I have a trouble here. Please help me
Guard declaration:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'admin-api' => [
'driver' => 'token',
'provider' => 'admins',
],
],
please check your code it should be like this.
auth()->id()
try with it
auth()->guard('admin')->id();

LinkedIn API Publish on network (S_412_PRECONDITION_FAILED=Invalid arguments)

When I try to publish a link on my own LinkedIn profile via the LinkedIn API, I get this error:
LinkedIn return error
Request Error: Invalid arguments: {S_412_PRECONDITION_FAILED=Invalid arguments}
My request:
$li = new LinkedIn([
'api_key' => env('LINKEDIN_KEY'),
'api_secret' => env('LINKEDIN_SECRET'),
'callback_url' => env('LINKEDIN_REDIRECT_URI')
]);
$li->setAccessToken('my_token');
return $li->post('/people/~/shares', [
'content' => [
'title' => 'This is an example of title',
'description' => 'This is a text with less 256 caracters.',
'submitted-url' => 'https://www.google.fr/',
],
'comment' => 'This is comment with less 700 caracters.',
'visibility' => [
'code' => 'anyone'
]
]);
I use the official API of LinkedIn (linkedinapi/linkedin).

Woocommerce REST API how send custom meta?

Woocommerce not send meta with custom plug-ins in format .json.
What should I add to the file functions.php?
How to forcibly compel him to send some meta?
Sorry for such a simple question, but I have not found a solution for spaces google
Send the following payload to the API:
$data = [
'name' => 'Product Name',
'type' => 'simple',
'regular_price' => '19.95',
'description' => 'Simple Product,
'categories' => [
['id' => 1]
],
'virtual' => true,
'reviews_allowed' => false,
'meta_data' => [
[
'key' => '_custom_meta_1',
'value' => 'value1'
],
[
'key' => '_custom_meta_2',
'value' => 'value2'
]
]
];
the "meta_data" field, should be an array, containing arrays with "key" and "value" attributes.

Sonata Admin - A2LiX Translation Field + Sonata Formatter Type

I've plugged Formatter (with CKeditor) to the 'content' field in one of my Sonata's Admin classes. This 'content' also has a translation, that's editable through 'a2lix_translations_gedmo' translations type. I've been trying to add CKeditor to this field as well, but it throws exceptions in any configuration I'm trying to set.
Google knows nothing about it, as well as SO. I've also looked in Sonata News Bundle sources (where sonata_formatter_type is implemented), but there are no translations available.
My Formatter field:
->add('content', 'sonata_formatter_type', [
'label' => "Content",
'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(),
'format_field' => 'contentFormatter',
'source_field' => 'rawContent',
'ckeditor_context' => 'my_config',
'source_field_options' => [
'attr' => [
'class' => 'span10', 'rows' => 10
]
],
'listener' => TRUE,
'target_field' => 'content'
])
My Translation fields:
->add('translations', 'a2lix_translations_gedmo', [
'label' => "Управление локализациями",
'translatable_class' => 'AppBundle\Entity\Article',
'fields' => [
'content' => [
'locale_options' => [
'ru' => [
'label' => 'Контент'
]
]
]
]
])
Maybe someone knows how to add 'sonata_formatter_type' to this damn 'a2lix_translations_gedmo' type (or 'a2lix_translations')?
'a2lix_translations_gedmo' or 'a2lix_translations' depends of the translation strategy chosen.
Gedmo strategy is discouraged and you shoud use a more recent translation strategy like the KnpLabs that I recommend. https://github.com/KnpLabs/DoctrineBehaviors#translatable
Othewise, see https://github.com/a2lix/TranslationFormBundle/issues/177#issuecomment-94949480

Resources