How to handle deleted app device token in Pushwoosh? - java

I am using Pushwoosh for sending notifications to Android and iOS apps from Java Webservices. I found it very easy to use.
I have successfully implemented it. I am using createMessage method with multiple device tokens for sending notifications.
I have used it for many times, and was getting proper response. But after some time I'm getting some device tokens in UnknownDevices key in a response. It is because some devices have deleted the app.
So is there any way that I can handle this situation that not sending notifications to devices which have deleted the app? How can I know that device has deleted the app?
Does Pushwoosh blocks account if I keep sending notifications to devices which has deleted the app?
Thanks

There are two ways of handling this:
Send pushes via Tags feature, where you set Tags on the device with the setTags method, not with push tokens. We will remove invalid/expired tokens for you.
You can use getUnregisteredDevices method, which is currently not documented publicly, but the Support team can provide details. the only disadvantage of this method is that it does not return iOS tokens handled by Apple feedback Service.

Related

Communication between BLE device and different android apps on same device

I'm new in Android BLE so my question may be uncorrect or naive in some way. If this is the case please explain me where I'm wrong and kindly show me the correct way to manage this scenario.
Scenario is the following: my Android app communicates with a BLE device sending commands and getting answers from device using BLE characteristics.
Sequence is:
Device wakes up the app (the onConnectionStateChange method is called)
My app writes a command in a characteristic (I call writeCharacteristic putting the command in value parameter).
Device sends back the answer to command to my app (the onCharacteristicChanged method is triggered and value parameter contains the answer)
After waking up the app, the device doesn't do anything until a command is sent via writeCharacteristic. The device accepts different commands.
All good so far, but recently I developed a second different app to communicate with same device.
When I run both apps on same Android phone, one app sends a command to the device and the response is received by both apps! Of course the app that didn't sent the command receives an unexpected answer and goes to an unexpected status.
Ok, knowing the problem I can modify both my apps to handle this situation, but the question is: Is this behavior normal when two apps in same device communicate with same BLE device?
Is there a way for an app to establish a communication channel with a BLE device to avoid sending answer to specific commands to any other app except the one that sent the request?
My guess is that writeCharacteristic and onNotificationChanged aren't the right functions for such kind of communication, but in this case which are the alternatives?
The Bluetooth standard itself doesn't define anything how multiple apps would behave if both have a GATT connection to the same device. In the standard there is just one "GATT client".
Now both iOS and Android have taken one step further in a way that might seem unintuitive. Instead of only allowing one app at a time to communicate, multiple apps can be connected over the same GATT client to a device. The OS "multiplexes" the communication from/to the apps. The behaviour is that responses to read and write requests can only be seen by the app that made the request. So if you do readCharacteristic only that app will get the onCharacteristicRead callback. Notifications however will be delivered to both apps to the onCharacteristicChanged callback, since it wouldn't make any sense to send the notification to only one.
When you say that the "response" to a write request is the notification, that's not correct in terms of GATT terminology. The response to a write request is always empty per specification (or an error). If your peripheral emits a notification, then in your case that might be the "answer" according to your own logic, but it's not a response or any way related to your write request per the GATT specification. That's why Android can't (and shouldn't) send the notification to only one device.
I suggest that you simply ignore notifications you are not expecting. If you want to associate an "answer" to a write request, you can change your protocol to include a transaction id in both packets so they can be matched.
When I write "app" above, I really mean BluetoothGatt objects. You can call connectGatt twice with the same remote device in the same app, which will behave the same as if you connected from two different apps.

How to send a notification from an android app to another android device using phone number?

I am developing an android application and i need to send a notification from the app to a phone number (another device).
Can anyone tell me how can i implement this? any methods or API i can use?
Thank you in advance
I don't think you can do it without developing server-side software that Android devices will connect to. In your server-side software you can use FCM(Firebase Cloud Messaging) or any other framework/library to send notifications to one or group of devices.
Problem is that you need to have connection to the other device and you can't know if that device is connected to internet and even if it is you don't know the address of that device. 99.99% that you need server-side software.
the easiest way (but the most expensive i guess) is to have the first device send a request to a server (whose backend you have to build, eg. php) that will send a push notification to the second device via Google Cloud messaging service.
that's not so easy because the second device to receive the notification must register at GCM and the first device must identificate the id of this device (the common way is to have a common id like username)
There is on possibility without using server side code, Send SMS to the second Phone and read the SMS in second phone and display your notification in second phone. It will cost the SMS charges in both phones.
Create an API that communicates with the users of the application this will be able to send updates to the registered users at real-time.
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

Sending APNS notifications with Java

I am currently developing Java web services that run on WebLogic on a server. There is a requirement that I need to send push notifications to mobile devices running on iOS. I do know what is required for developing GCM/FCM for sending notifications to Andriod devices. For iOS, I know there is APNS, but what Java library can I use to send the notifications?
Also, what are the required things (registration ID, etc) needed in order to send via APNS?
Any example codes?
I have googled and found out about java-apns and javapns, but I am not even sure if they are obsolete already.
Thanks in advance.
I can help you with what all are the things which are must to implement APNS. Please note that with the introduction of new HTTP/2.0 APNS API, a lot of things have changed which used to be before. (Good news is : Things have really become easy & simple now)
Would advise you to go through the below link:
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/Introduction.html
APNS Prerequisites:
1) APNS SSL Certificate, Key (Same for sandbox & production now, previously used to be different for production/development/voip etc. This is the most important step, as most of the issues related to APNS are due to the wrong certificate generation)
2) device token (specific to per iOS app running on an iOS device, your iOS client app needs to register with APNS to get this device token. Also device token is normally different for development & production environments. So please make sure your using the right token)
Once you have above mentioned certificate,key & device token for your iOS App, you can send APNS notifications from your application provider using APNS interface.
Please note that, device token can change anytime (normally during iOS software upgrade), so its always advisable to obtain fresh device token every time your app is launched.
On your query related to java library for apns, please note new APNS interface has a dependency on HTTP/2.0 . Both open source as well as enterprise versions (like AWS, Urban airship etc) are available which you can select based on your needs. Not sure if AWS supports new HTTP/2.0 interface. However its always advisable to use the latest APNS interface as per Apple guidelines.
Optionally, you can also use GCM as well to implement APNS.
https://developers.google.com/cloud-messaging/ios/start
However, your iOS app may need to register to GCM as well for the same. Basically the iOS device token will be mapped to GCM device token. However, you would still need to generate certificate,key as well as device token as I have mentioned.
I hope it answers your query.
_Ayush

Open my mobile Java program with SMS, no SMS in inbox

Is it possible to open my mobile Java program with an SMS?
And I don't want this SMS to be stored in the inbox. I'm looking for the kind of "Control SMS" that banks use for their mobile applications. I want the same in my application: send SMS to the mobile, the mobile device shows a message on screen that will be opened by the program, and this SMS should not be saved in the inbox.
Are you sure that you're not mistaking push notifications/cloud to device messages for SMS's?
Push/C2D messages are similar to SMS's inasmuch as a central server sends a message out to devices and many apps then display a popup based on that message, but the implementation is completely different. If you're not mistaking the two, is there a reason you'd prefer to use SMS's that are handled differently than most instead of push/C2D messages?
Here's the documentation for Apple's Push Notification Service.
Here's Android's Cloud to Device Messaging documentation which serves the same purpose.
Have a look and see if that would serve your needs.
If you are looking for completely client side J2ME based solution for feature phones - then try push registry. It is available above MIDP2. I don't know the exact details but there you can define event and triggers which will be stored by phone OS and invoked automatically when particular type of event occurs.
SMS sending is separate issue but there are tools available for that definitely.

Getting device characteristics and network information

I am developing a context aware mobile application. I need to have information about the capabilities of terminal devices and network characteristics such as current bandwidth. My question is, are there APIs in android to access this information?
Thanks.
The better question is, are there APIs for these terminal devices to access the information from outside. Of course you can get the bandwidth of your phone to the provider, but to get that info of the terminal device, you need to access their data.
I would suggest a three-way request for that. At first there is a webservice, in your language of choice, e.x. PHP, which has to get access to the terminal device. That device has to publish their data somehow, so thats the first point you need to know.
Then this webservice cleans the data like you need it and publish it as xml or json or whatever.
Then your App in Android acceess the service to get the info and parse it into your app.
There are alot posts here to find out, how to get a HTTP Request Result. For parsing XML you can find something here:
http://www.ibm.com/developerworks/opensource/library/x-android/index.html
For accessing a network device with a specific port an such stuff, you can use PHP with the function fsockopen()

Categories

Resources