Comments (13)
Oh, iPhones (since iOS) now use unified emoji, so you really want:
"\xF0\x9F\x98\x84 Vei na..."
Which is codepoint U+1F604
from php-emoji.
It's as simple as using double quotes:
$body['aps'] = array('alert' => "\xf0\x9f\x98\x84", 'sound' => 'default');
After calling json_encode()
on that, you'll get:
{"aps":{"alert":"\ud83d\ude04","sound":"default"}}
...which is correct JavaScript unicode escaping.
from php-emoji.
That's not how you escape UTF-8 in PHP. Try this:
"\xEE\x90\x95 Vei na..."
You can find the UTF-8 bytes for a codepoint using this: http://unicodey.com/?cp=e415
from php-emoji.
Cal, can you explain it with more details, please?
from php-emoji.
- How are you sending the message to APN? Using what language and what code?
- iOS no longer uses
\ue415
- you should be using\u1f604
from php-emoji.
We try to send emoji from php webservice.
We using this Lib to send on php
https://github.com/duccio/ApnsPHP
from php-emoji.
It looks like ApnsPHP does some special handling for Unicode. Try this:
$message->setText("Emoji: \\uD83D\\uDE04");
Apns expects 4-nibble \u
escapes with a literal slash. To encode an emoji like U+1f604 you need to split it into two surrogate pair codepoints. I used the calculator here: http://www.russellcottrell.com/greek/utilities/SurrogatePairCalculator.htm
from php-emoji.
I am trying to send push notifications with emoji using php. For sending push notifications, I started with this tutorial and have got the push notifications working.
For sending emoji in push notifications from my php server, I tried with following code snippets, but all I keep getting in the notification is the Unicode characters as it is.
Here are some code snippets I tried...
$body['aps'] = array('alert' => '\xe2\x98\x81 Check', 'sound' => 'default');
$body['aps'] = array('alert' => emoji_unified_to_softbank('\xe2\x98\x81 Check'), 'sound' => 'default');
$body['aps'] = array('alert' => emoji_softbank_to_unified('\xe2\x98\x81 Check'), 'sound' => 'default');
What I should be getting here is a cloud emoji followed by the string 'Check'. But what I get is simply the string, \xe2\x98\x81 Check
. I saw that the message looks like this in the payload (I am using json_encode
to convert the payload that is a php array, to json encoded format):
\\xe2\\x98\\x81 Check
The reason could be that the payload has to be converted from php array to json-encoded format.
$payload = json_encode($body);
What am I doing wrong here? Can somebody help me out with this?
from php-emoji.
Hi dudu I try a lot of tutoriais, but the only step which works is change mysql encoding: Try this:
http://mathiasbynens.be/notes/mysql-utf8mb4
from php-emoji.
Hi alex, I did not make use of mysql anywhere. The emoji code is hard-coded into the payload in php code.
from php-emoji.
vikkun: it all depends on the library doing the push notifications. Apple wants to recieve JSON looking like this:
"body" : "\u2601"
so try the following PHP:
$body['aps'] = array('alert' => '\\u2601');
from php-emoji.
iamcal: After referring your earlier comment, I am trying to use the unified emoji codes. But \\u2601
did not work either.
Here is my gist of what I am trying to do. It seems that since I am json encoding my payload, escaping the slash does not work.
// Create the payload body - emoji for smiling face with open mouth and smiling eyes
$body['aps'] = array('alert' => '\xf0\x9f\x98\x84', 'sound' => 'default');
// THIS IS WHAT SEEMS TO BE CAUSING THE EMOJI CODE TO APPEAR AS IT IS ON iPhone
$payload = json_encode($body);
Is there some workaround to this situation?
from php-emoji.
Does emoji works with APNS Java code? If yes, could you please share code snippet ?
from php-emoji.
Related Issues (20)
- No background-position for emoji1f320 (U+1F320, shooting star) HOT 1
- Composer support HOT 13
- generate a map with the latest emoji available HOT 9
- Not working. HOT 2
- Error Cannot redeclare emoji_docomo_to_unified()
- Problem to send Camera Emoji in Push Notification
- Retina support HOT 2
- Many emojis aren't supported on emoji_unified_to_html HOT 1
- Emoji picture is too large. HOT 1
- emoji1f610 wrong positioned HOT 2
- emoji_name_to_unified
- NN
- Adding extra emojis! HOT 10
- update composer version HOT 2
- Emoji picker corresponding with this library?
- Some emoticons leave residual data in the string after conversion HOT 4
- False positives for emoji_contains_emoji HOT 1
- Some Emoji Still Not Supported
- Emoji's don't work with APNS-PHP HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-emoji.