Codename One - Show number of unread messages in the app icon - android

Please look at the Signal icon in this screenshot:
My question is how to obtain the same result in a Codename One app. Suppose that my app has a variable like "int unreadMdg", how can I show the number of unread message in the app icon?

We currently only support this on iOS as it wasn't available on any Android device when we launched the feature and is still arguably flaky on Android.
For iOS support you can set the badge value via push notification (see the developer guide) or by using the API:
if(Display.getInstance().isBadgingSupported()) {
Display.getInstance().setBadgeNumber(unreadCount);
}

This is for IOS
Use this to make it displays a specific number
// Objective-C
[UIApplication sharedApplication].applicationIconBadgeNumber = number;
// Swift
UIApplication.shared.applicationIconBadgeNumber = number

Related

SMS to prefilled text message on Google Pixel

I am trying to create a link in an email that will open a mobile device's default texting app if pushed. Here is what I have so far:
a href="sms:;?&body=This%20is%20the%20body%20message."
I have tested it and it seems to work on iOS devices as well as some Android devices. However, on a Google Pixel 3, it opens the default messaging app but shows an error which reads Could not start conversation.
How can I change my code to successfully open a conversation with a blank recipient?
After hours of trial and error, I was able to prefill the Pixel (3XL), iOS (simulated in Xcode), and macOS Messages using the following structure:
Pixel: sms://+1${PHONE}/?body=${encodedString}
iOS: sms://+1${PHONE}/&body=${encodedString}
Give this a try from a link, I think you need a number and replace ; with ?
Send SMS
For non iOS you want to use (For your Pixel Example)
sms:phone_number?body=The_Message
For iOS you want to use
sms:phone_number;body=The_Message

Push notification from Mixpanel dashboard to Android Cordova app

I am successfully sending Push Notifications from the Mixpanel Dashboard to a Cordova app on both iOS and Android devices, using phonegap-plugin-push.
However, the title and body values entered in the default fields only appear on iOS devices.
For the notification to appear on Android devices, I currently need to include a custom payload in Mixpanels "Custom Data":
{
"title":"Title for Android only",
"body":"Content for Android only"
}
This is an error prone step for any non-technical using Mixpanel to send notifications.
Does someone know an easier way to do this?
The short answer here is that Cordova/Phonegap and similar third party frameworks are not 100% optimized for Mixpanel functionality (although they work pretty great), and as such you'll need to generate separate push notifications for both iOS and Android in your Mixpanel project.
Providing context, all iOS pushes regardless of app deliver a JSON payload to APN using the same keys to deliver their messages (alert, badge, sound). However, the keys that Android apps process for incoming GCM pushes are entirely dependent on how the GCM receiver is established, and therein lies the problem here.
Mixpanel's Android SDK initializes pushes and uses a GCM receiver that is specific to Mixpanel messages, and fully expects its custom keys (mp_message, mp_title) in order to render the notification. The webapp reformats the message input to meet these key requirements (http://bit.ly/1OGgU1y)
However, the Phonegap GCM receiver expects different keys as you've noticed. I'd recommend referring to the phonegap github page in order to get more context into the expected push format and behavior (looks like they expect "title" and "message" as the keys): http://bit.ly/1KDScye
Unfortunately, what this means is that the Android app is not optimized to receive the default, web-app generated Mixpanel pushes, although your iOS one is. Mixpanel's SDKs are intended to maximize capabilities for that platform, and it isn't guaranteed that Cordova or similar JS frameworks will translate 100%.
So to conclude - Creating a message in the Mixpanel push editor will send to iOS, but for Android you'll need to use the custom JSON payload in a separate notification, including keys that the phonegap GCM receiver is compatible with.
If its help to anyone this is how I solved the problem
in phonegap-plugin-push
you need to modify two files
GCMIntentService.java
private String normalizeKey(String key) {
if (key.equals(BODY) || key.equals(ALERT) || key.equals(MP_MESSAGE) || key.equals(GCM_NOTIFICATION_BODY)) { // added MP_MESSAGE
PushConstants.java
public static final String MP_MESSAGE = "mp_message";

Adobe Air - Sending pre-populated SMS via Android

I'm trying to send a pre-populated SMS via AS3 in Adobe AIR. It works perfectly on iOS, with the native SMS UI displaying with the pre-populated text. However on Android it's seeing the whole string as the phone number, showing the following error -
Invalid recipients(s): <0123456789&body=Hey! This is a test message.
http://google.com>
The code I'm using -
var number:String = "0123456789"
var callURL:String="sms:"+number+"&body=Hey! This is a test message. http://google.com";
var targetURL:URLRequest = new URLRequest(callURL);
NavigateToURL(targetURL)
1st) The & that you are using should be an ?
sms:+15105550101?body=hello%20there
Refer to RFC 5724 for details.
Note: on iOS8+ the & is correct, for iOS7 and under use an ;
2nd) Certain Android versions are just plain broken when it comes to including a 'body' in an SMS URI. You would need to look up the 'buggy' versions in Google's bug database.

Azure notification hub cross platform push

I need to send a push notification to mobile devices that have registered on my notification hub.
The hub is set up to allow windows phone, apple and android devices to register, and I have the appropriate keys and certificates in place. (According to the documentation!)
I am using the latest release of the Microsoft.Azure.NotificationHubs namespace, version 2.16, as advised by the NuGet package manager.
I want to send one message, to all registrations as well as sending a message to a specific device. I can see the devices have all registered correctly with the hub, and have tags that allow me to send notifications to them.
I am trying to use the SendDirectNotificationAsync() method
that takes a Dictionary and a string tag as parameters.
I have also tried the SendNotificationAsync() method that takes a Notification object as a parameter.
Neither method causes a notification to appear on my windows phone with the parameters I have provided, so without an example or more information from the help files, I am stuck.
I cannot find any current examples using these methods and classes.
The examples I have found pre-date the release, and do not show what to send to the notification hub for a cross platform notification to work.
I know these have only just been released, but any help / guidance would be appreciated, as I have reached a complete dead-end with this.
Just a quick update...
Although I never got this to work as I wanted to (as described above), what I ended up doing was to use each platforms native notification as below;
var result1 = await hub.SendMpnsNativeNotificationAsync(windowstoast, mobileDeviceId);
var result2 = await hub.SendGcmNativeNotificationAsync(androidToast, mobileDeviceId);
var result3 = await hub.SendAppleNativeNotificationAsync(iOStoast, mobileDeviceId);
The 'toast' was formatted as per the individual platforms requirements in the documentation.
The 'mobileDeviceId' was the tag that each device registered with the notification hub.
So, clumsy, but it works reliably to achieve the same end.
I still would like to get the cross platform way to work though. Will look into it a bit more when I have time.

Google Cloud Messaging: How to show an icon and group messages

I have two questions regarding Google Cloud Messaging:
(My push script is PHP, and my client is Corona SDK.)
PUSH ICON: Currently, my push messages are displayed on the screen with an icon that looks like an inverted triangle with an exclamation mark inside. How do I make it show my own icon? (Can I dictate the icon from the server, or must this be done on the client?)
GROUPING MESSAGES: Currently, if I send three push messages to the phone, they are shown individually in the push list, whereas in other apps, subsequent push messages all replace the previous one, so they only take up one place in the list. How do I accomplish this? Is this the collapse_key value?
Thanks!
First of all, you should have specified "Google Cloud Messaging" (or C2DM in case) in the title of this thread, rather than "Android Push"...
1) If you don't set any custom icon, devices borrow, I don't know why, icons from other installed apps (the icon of Google Talk, sometimes). You can set your own icon from client with the following code:
String app_name = context.getString(R.string.app_name);
int icono = R.drawable.ic_stat_notify;
long time = System.currentTimeMillis();
Notification notification = new Notification(icono, app_name, time);
And you should follow the official Android Design Guideline to design that custom icon, usually designing three versions of the icon (one for devices running v2.2, another for devices running from v2.2 to v3.0 and another for devices running from v3.0).
2) Yes, that's exactly the collapse_key purpose.

Categories

Resources