ALL GCM parameters? - php

i´ve written a "pushserver" for my app via PHP.
The push notifications i´ve sent via PHP are all received on the device, so far.
But, i can just send/set the "message" and "title", see:
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array(
'message' => $message,
'title' => 'My App',
'vibrate' => 1,
'sound' => 1,
'icon' => "http://example.com/image.jpg",
"style" => "inbox"
),
);
"icon" and "style" are not working (vibrate and sound not tested, yet).
Every link for the parameters i´ve found is broken or kind of "you need to do object.setSomething() in JAVA.
Is there a list anywhere where i can see ALL parameters, which i can send to GCM? No matter, what language i use?
Cheers,
Chris

couple of things need to keep in mind while all the data which you sending from server end
Is there a list anywhere where i can see ALL parameters,
exp :- you can send as many parameters as you want but offcourse there is limitation but not key specific just like you can use "textmessage" instead of "message" but make sure to retrieve the value from same key which you are assigning from server end
1) please make sure that you are getting all the data in gcmintentservice class try to print the log of all intent data.
please remember that this is just a string data it is not going to download the image for you. you have to download using volley library or any suitable library

Related

How to send Push with different data for each token in Firebase?

There is such a code, but it sends a single message to all the tokens specified in the array (1000 tokens). You need to add a personal parameter for each token somewhere to track the unique click - from whom it comes and so on. For example, in click_action. But again, if you add a parameter there, the link in this form will be sent to everyone. Sending one message for each user is not an option, of course.
'registration_ids' => $tokens,
'data' => array(
'title' => 'Title',
'body' => 'Message',
'icon' => 'icon.png',
'image' => 'image.png',
'click_action' => 'https://site.ru'
);
There is no (mail merge like) customization for each recipient within a single API call. Each call to the FCM API to send a message, sends precisely the message you pass in that call to the topics/tokens you target in that call.
If you want recipients to receive a different message, you will need to perform one API call for each message.
You say:
Sending one message for each user is not an option
Calling the API fo each unique message is precisely the only option. I'm not sure why it wouldn't be, as it's what all apps using FCM do if they want to deliver personalized content.

sending message to slack channel using PHP/Guzzle prints "Array"

I'm trying to post to a Slack channel but it's not working as intended.
The only message I get in Slack says Array, as in that the value of text is an Array. As I'm understanding their docs, it shouldn't do that. If I move the text to the first level of the array, the actual text is displayed, so I'm guessing that my request is working fine. What am I missing? This is being done in PHP with GuzzleHttpClient.
My message:
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => 'This is supposed to be my text'
]
];
My request to the API:
$request = $client->post($url, [
RequestOptions::JSON => $messages
]);
It seems not as obvious, but you cannot use the message formatting used for their API chat.postMessage for incoming webhooks. Both have different formatting.
With that said, follow this documentation for webhook messages and it's respective formatting here.
What you were trying to do is use so called "blocks" which seems to be dedicated to their API messaging instead.
If you try your message on this message builder (which is intended for webhooks), it will fail. But it will work on this message builder.
Perhaps you can get away with using new-lines if you want your message to appear over multiple lines. See here.
As #ncla mentioned, if you are using "Block UI" elements, using the incoming webhook API, you cant send the blocks as with the chat.postMessage.
Its not obvious on the Blocks documentation, but in the
Messages payload page it specifies that you can send a blocks attribute. This will allow you to use the Blocks structure.
Your structure is incorrect, see documentation: https://api.slack.com/messaging/composing/layouts#stack-of-blocks
It should be array of message blocks, you need to nest it further one time.
[
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => 'This is supposed to be my text'
]
]
];

Build APP using specific keys via Phonegap Build API?

I'm trying to use Phonegap Build API.
I am using this open source PHP library to connect to the Phonegap plugin.
https://github.com/mradionov/phonegap-build-api
Everything works fine as it should.
I can add keys, upload apps and all other general tasks.
However, the issue that I currently have is that I need to be able to upload the app and build it using a specific key for each platform.
To upload the app I use this method:
$res = $api->updateApplicationFromFile(3334534, 'path/to/myapp.zip', array(
'title' => 'The APP title',
// see docs for all options
));
This uploads it correctly and as it should.
Now, i tried to upload the app using the same method but select a specific key to build it with like so:
$res = $api->updateApplicationFromFile(3334534, 'path/to/myapp.zip',
'title' => 'The APP title',
'keys' => 1435671
// see docs for all options
));
But this fails to do anything and I dont see any errors either!
Based on the Phonegap API documentation, we can send the following to the API:
keys":{"ios":123,"android":567,"winphone":72}
the numbers used are the keys/certficates that already uploaded onto the Phonegap system.
Could someone please advice on this issue?
Thanks in advance.
finally found it.
Basically I need to pass the values as an array like so:
'keys' => array("ios" => XXXXXXX, "android" => XXXXXXXX),
So the code looks like this:
$res = $api->updateApplicationFromFile(3334534, 'path/to/myapp.zip',
'title' => 'The APP title',
'keys' => array("ios" => XXXXXXX, "android" => XXXXXXXX),
// see docs for all options
));
And this works just fine...
Hoep this helps others.

Laravel Push notifications: Send silent push notification

I am using this to send push notification to iOS and it is working fine except the fact that I don't know how to send a silent push using this package. I have tried to send it like this:
$payload = PushNotification::Message('', array(
'aps' => array(
'content_available' => 1,
),
'data' => array(
'actionType' => $actionType
)
));
Sending empty string in the first param of ::Message, it does not show anything on mobile screen but it does produces the sound. Secondly, I tried it without the presence of this param. But if this param is not present, it throws exception. How to send silent push? Any ideas?
My Laravel version is 5.4.
Such a trivial mistake that I made in the code shown above in the question is to use content_available instead of content-available.

Example of sending POST and FILES data from iPhone to a remote PHP website

I'm programming an API of sorts on a PHP website I built with the goal that another programmer can send data (POST and FILES date) to my PHP website from their iPhone app so that I can process the data and return some of my own.
We've been struggling to find a way that he can send POST data (though we found a pretty hacky workaround) and FILES data from the iPhone app. The goal on my end would be to receive a POST array and a FILES array similar to (in PHP of course):
$_POST = array(
'key' => 'key-value-here',
'token' => 'token-value-here',
'id' => 'id-value-here'
'values' => array(
'name' => 'Name value here',
'description' => 'Description value here'
)
);
$_FILES = array(
'photo' => array(
'name' => 'photo-name.jpg',
'type' => 'image/jpeg',
'tmp_name' => '/tmp/path',
'error' => '0',
'size' => '12345'
)
);
Any help you could offer us on how we could send such data would be greatly appreciated. Also, the iPhone app programmer is trying to avoid using the ASIHTTPRequest library for now (for a number of reasons).
Just create a multi-part post. For how it should look like, see a multi-part message. I have never worked with the iPhone, so I couldn't tell you which library could do this, but if all else fails, it's just an open socket connection & some string manipulation...

Categories