I want to send a Push Notification message to particular iPhone device using Java.
I dont have any idea how to do this.
I have googled on this, they have suggested to use "PayLoad" class but not getting this class from any jar files.
Please anybody can guide me to send the push notification message to iPhone suing Java?
Use JavaPNS. Here is an exaple:
import javapns.Push;
public class PushTest {
public static void main(String[] args) {
Push.alert("Hello World!", "keystore.p12", "keystore_password", false, "Your token");
}
}
Use parse sdk from www.parse.com , it helps in delivers a good way to handle push notification between ios and android(offcourse its java). Its really simple to work along with it..
The example on the parse.com site is not good for android, so i am giving the link of the site where the steps are much easier to work with
http://developingonandroid.wordpress.com/2011/11/24/3-android-push-notifications-in-parse-a-deep-overview/
Related
I implemented my backend service (using java and FCM) to send push-notifications to mobile apps.
I implemented my service using Java Firebase Admin-SDK (https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/messaging/package-summary and https://firebase.google.com/docs/cloud-messaging/send-message#java) about this and I'm able to send (and receive) push notifications on iOS and Android mobile apps.
Now I received a request from mobile-developers that they needs to customize (client-side) the received push notifications (also when the app is in background mode).
Probably here is reported a same question: What is the difference between Firebase push-notifications and FCM messages?
Reading the documentation (https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages) I understood that It's necessary to use a Data-message instead of a Notification message.
It's not clear for me what's necessary to change to support this delivery type.
Do I change the Android-config of the FCM-message or Do I remove some unnecessary data (just set all info into the custom data without others info for example Android configuration etc..)
It's possible to have a small example?
If your json will have notification key, developers will not able to handle notifications in background. They will receive this notification only when app is in foreground. In case when developers should receive “silent pushes” or they need control all notifications, you should remove notification key, and use only data key.
This can be achieved by changing the key 'notification' to 'data' as follows:
{
"notification": { //replace this line by "data"
"title": "Hey Gajanan",
"body": "Thanks for visiting omnidecoder.com"
},
"to" : "YOUR-GENERATED-TOKEN"
}
Hello my dear friends,
I'm trying to send back a read receipt for push notifications to Amazon's Pinpoint, so I can know when users have read a push notification previously sent to my apps. On iOS, in Swift, that's possible by using the following piece of code:
var pinpoint: AWSPinpoint?
AWSMobileClient.sharedInstance().interceptApplication(application, didFinishLaunchingWithOptions: launchOptions)
pinpoint = AWSPinpoint(configuration: AWSPinpointConfiguration.defaultPinpointConfiguration(launchOptions: launchOptions))
AWSDDLog.add(AWSDDTTYLogger.sharedInstance)
AWSDDLog.sharedInstance.logLevel = .info
I found something related to that in the documentation, but it's not quite clear on how to send it back on Android. They create some sort of Login view, which is not exactly what I want.
My question is: how do I send that response - a read receipt to my push notification - back to Pinpoint on Android?
Thanks in advance.
Assuming you are using the Pinpoint mobile SDK and it is set up properly this receipt is supposed to be generated automatically by the SDK itself.
I've started on making my own Skype app using Java Skype Api from taksan
https://github.com/taksan/skype-java-api
(I prefer Java instead of C# because I don't know C# yet)
But my simple method on sending message doesn't work. I don't know if I'm missing something or they updated skype and therefore this api is outdated.
I tried two methods in Java FX called from a button. Both should send testing message to one of my friends. And yes, I've allowed the program in skype.
private void sendMsg2() throws SkypeException {
Skype.chat("skype_ID").send("Sending test message ...");
}
private void sendMsg(Friend[] friends) throws SkypeException {
for (Friend akt : friends) {
if (akt.getId().equals("friend's skype ID")) {
akt.send("Test message 2");
System.out.println("Sending test message 2...");
}
}
}
Both have same results. Message won't send. Look at the picture: http://imgur.com/dfXyV1t
I'm trying to send message to one person (so it's not chat group). Any suggestions please?
I'll first say that I'm sure it is just me since people have probably got this to work out of the box without having to edit the ADAL 4 Android Library without editing the source.
When running the sample program and authenticating with a token I get an error from AZURE that it is not passing the client_secret in the message body. I can confirm that this is in fact the case - it is not passing the client_secret.
Although if I edit the OAuth2.java file and change the method buildTokenRequestMessage to something like the following the workflow works perfectly
public String buildTokenRequestMessage(String code) throws UnsupportedEncodingException {
String message = String.format("%s=%s&%s=%s&%s=%s&%s=%s&%s=%s",
AuthenticationConstants.OAuth2.GRANT_TYPE,
StringExtensions.URLFormEncode(AuthenticationConstants.OAuth2.AUTHORIZATION_CODE),
AuthenticationConstants.OAuth2.CODE, StringExtensions.URLFormEncode(code),
AuthenticationConstants.OAuth2.CLIENT_ID,
StringExtensions.URLFormEncode(mRequest.getClientId()),
AuthenticationConstants.OAuth2.REDIRECT_URI,
StringExtensions.URLFormEncode(mRequest.getRedirectUri())
// these are the two lines I've added to make it work
AuthenticationConstants.OAuth2.CLIENT_SECRET,
StringExtensions.URLFormEncode("<MY CLIENT SECRET>")
);
return message;
}
Am I doing something wrong? If not, what is the correct way to access the client secret?
My implementation is straight from the demo application with only changes being setting up the strings to match my endpoints.
Thanks
You need to register your app as a Native application at Azure AD portal. You don't need client secret for native app.
I know that the SMS content provider is not part of the public API (at least not documented), but if I understand correctly it's still possible to use many of the SMS features as long as you know how to use the API(?).
E.g it's pretty straightforward to insert an SMS into your inbox:
ContentValues values = new ContentValues();
values.put("address", "+457014921911");
contentResolver.insert(Uri.parse("content://sms"), values);
Unfortunately this does not trigger the standard "new-SMS-in-your-inbox" notification. Is it possible to trigger this manually?
Edit: AFAIK the "standard mail application (Messaging)" in Android is listening for incoming SMSes using the android.permission.RECEIVE_SMS permission. And then, when a new SMS has arrived, a status bar notification is inserted with a "special" notification id.
So one solution to my problem (stated above) could be to find, and send the correct broadcast intent; something like "NEW SMS HAS ARRIVED"-intent.
Edit: Downloaded a third party messaging application (chompsms) from Android market. This application satisfies my needs better. When i execute the code above the chompsms notice the new sms and shows the "standard status bar notification". So I would say that the standard Android Messaging application is not detecting sms properly? Or am I wrong?
Unfortunately the code responsible for these notifications is hidden in the messaging application. The class MessagingNotification has a static method updateAllNotifications that you could call using a PathClassLoader and reflection:
PathClassLoader c = new PathClassLoader("/system/app/Mms.apk", getClassLoader());
Class.forName("com.android.mms.util.ContactInfoCache", true, c)
.getMethod("init", Context.class).invoke(null, context);
Class.forName("com.android.mms.transaction.MessagingNotification", true, c)
.getMethod("updateAllNotifications", Context.class).invoke(null, context);
This is obviously a very bad idea for several reasons but I can't think of another way to do what you described.
Could you trigger a PUSH notification after the SMS?
Thread: Does Android support near real time push notification?
Maybe you should replace
content://sms
with
content://sms/inbox