Quantcast

Latin Characters in Push Notification

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Latin Characters in Push Notification

LinkZ
Hi Folks,

I am trying to send push notifications using following code...

curl:
"curl -u "XXXXXXXXXXXX" -v -H "Accept: application/json" -H "Content-type: application/json;charset=UTF-8" -X POST -d '{"alias" : ["12345678912"], "ttl" : 3600, "message": { "alert":"Do it faça.", "sound":"default", "badge":0, "idNotificacao":1}}' pushserver.pt/rest/sender

My Handler:
...
public class NotificationBarMessageHandler implements MessageHandler {
    public static final int NOTIFICATION_ID = 1;
    private Context context;

    public static final NotificationBarMessageHandler instance = new NotificationBarMessageHandler();

    public NotificationBarMessageHandler() {
    }

    @Override
    public void onMessage(Context context, Bundle bundle) {
        this.context = context;
        //Here I get the message without latin character.
        //message = "Do it faa".
        String message = bundle.getString(UnifiedPushMessage.ALERT_KEY);
        NFPApplication application = (NFPApplication) context.getApplicationContext();
        application.addMessage(message);
        notify(bundle);
    }
...
}

AndroidManifest:
...
<receiver
    android:name="org.jboss.aerogear.android.unifiedpush.gcm.AeroGearGCMMessageReceiver"
    android:permission="com.google.android.c2dm.permission.SEND">
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="br.empresa.cliente.projeto" />
    </intent-filter>
    <meta-data
        android:name="DEFAULT_MESSAGE_HANDLER_KEY"
        android:value="br.empresa.cliente.projeto.handler.NotificationBarMessageHandler" />
</receiver>
...

VMOptions:
...
-Dfile.encoding=UTF-8
...

When the message is in English, latin charset, everything works. However, when I try other languages or the character ç, they are deleted from the string.

Note: When I test the iPhone everything works fine, but when I test on Android have this problem to the same message.
It's encoded in utf-8, my database is MySQL deployed on a Linux server.


Thanks in advance.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Aerogear-users] Latin Characters in Push Notification

Summers Pittman
Which versions of Android, aerogear-android-push, and unified push server are you using?



On Wed, Jul 27, 2016 at 10:20 AM, LinkZ <[hidden email]> wrote:
Hi Folks,

I am trying to send push notifications using following code...

*curl:*
"curl -u "XXXXXXXXXXXX" -v -H "Accept: application/json" -H "Content-type:
application/json;charset=UTF-8" -X POST -d '{"alias" : ["<a href="tel:12345678912" value="+12345678912">12345678912"],
"ttl" : 3600, "message": { "alert":"Do it faça.", "sound":"default",
"badge":0, "idNotificacao":1}}' pushserver.pt/rest/sender

*My Handler:*
...
public class NotificationBarMessageHandler implements MessageHandler {
    public static final int NOTIFICATION_ID = 1;
    private Context context;

    public static final NotificationBarMessageHandler instance = new
NotificationBarMessageHandler();

    public NotificationBarMessageHandler() {
    }

    @Override
    public void onMessage(Context context, Bundle bundle) {
        this.context = context;
        //Here I get the message without latin character.
        //message = "Do it faa".
        String message = bundle.getString(UnifiedPushMessage.ALERT_KEY);
        NFPApplication application = (NFPApplication)
context.getApplicationContext();
        application.addMessage(message);
        notify(bundle);
    }
...
}

*AndroidManifest*:
...
<receiver

android:name="org.jboss.aerogear.android.unifiedpush.gcm.AeroGearGCMMessageReceiver"
    android:permission="com.google.android.c2dm.permission.SEND">
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION"
/>
        <category android:name="br.empresa.cliente.projeto" />
    </intent-filter>
    <meta-data
        android:name="DEFAULT_MESSAGE_HANDLER_KEY"

android:value="br.empresa.cliente.projeto.handler.NotificationBarMessageHandler"
/>
</receiver>
...

*VMOptions*:
...
-Dfile.encoding=UTF-8
...

When the message is in English, latin charset, everything works. However,
when I try other languages or the character ç, they are deleted from the
string.

Note: When I test the iPhone everything works fine, but when I test on
Android have this problem to the same message.
It's encoded in utf-8, my database is MySQL deployed on a Linux server.


Thanks in advance.



--
View this message in context: http://aerogear-users.1116366.n5.nabble.com/Latin-Characters-in-Push-Notification-tp767.html
Sent from the aerogear-users mailing list archive at Nabble.com.

_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users


_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Aerogear-users] Latin Characters in Push Notification

LinkZ
I'm using:

-Moto G1 running Android 5.1 and Samsung Galaxy Note 10.1 running Android 4.1.2;
-Aerogear Unifiedpush Server 1.0.3;
-Aerogear Android Push 2.2.1;
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Aerogear-users] Latin Characters in Push Notification

Summers Pittman
I was able to get the ç character to push successfully using UPS 1.2.0-alpha.1 and AeroGear-Android-Push 2.2.2 on Lollipop, Marshmallow, and Nougat (a mixture of emulators and devices).

There are several things you can do to figure out where the encoding error is happening.

First I would try sending a push message to your device bypassing UPS.  If you have access to a bash shell you can try the following gist : https://gist.github.com/secondsun/f659a34a43dd41c2a6509f2e5733f23f  Please note you will need to provide your own server ID and device ID (and both are available in UPS). 

If this works then the problem is between UPS and GCM and we can continue debugging from there.

On Wed, Jul 27, 2016 at 1:40 PM, LinkZ <[hidden email]> wrote:
I'm using:

-Moto G1 running Android 5.1 and Samsung Galaxy Note 10.1 running Android
4.1.2;
-Aerogear Unifiedpush Server 1.0.3;
-Aerogear Android Push 2.2.1;



--
View this message in context: http://aerogear-users.1116366.n5.nabble.com/Latin-Characters-in-Push-Notification-tp767p769.html
Sent from the aerogear-users mailing list archive at Nabble.com.
_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users


_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users
Loading...