Device Tokens are different from one device to another device - java

Hi i am little bit confusion about Device Token so can any one guide me. I am using following code for getting DeviceToken.
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)dt
{
}
The above code is working fine and it is showing DeviceToken data ,that is 64 length data.
My doubt is Device Token is different from one device to another device.
If once we got DeviceToken using one device that same DeviceToken can use for another Device.

Of course the device token is different for each device. It identifies a unique device. It's like a phone number (actually it's even more unique than a phone number, since multiple phones can have the same phone number). If it was the same, how would the Apple Push Notifications server know to which device to send your notification?

Related

Android Classic Bluetooth make UUID public

Seems like when made discoverable, an android device (A) doesn't show it's UUIDS, unless the device trying to get it's UUIDS (B) is paired with it.
Any body know how to make it's UUIDS public to any device ? By the way I'm not working with BLE, only Classic Bluetooth

java-apns badge count for each device?

I am using java-apns library. Here is my code:
String payload = APNS.newPayload().alertBody("Message").badge(2).build();
apnsService.push(tokens, payload);
Why there is many tokens and only one number for badge? Each phone has its own number of unread notifications! So there should be one number for one device. How do I get to be so?
p.s. sorry for my english.
The apnsService.push(tokens, payload) method is used for sending the exact same payload to multiple devices. If you wish to send a different payload to each device (and different badge counts mean different payload), you'll have to create a different payload for each device and call the push method for each device token separately (there's probably a version of that method that takes just a single device token).

Alternative method of getting Sim number if getLine1Number() returns null

I have written an app which sends a message to a number if the sim card of the phone is changed in other words if the phone number of the phone is changed. The code is working fine on android emulator but when I run this app on my phone, getLine1Number() of TelephonyManager class is returning null string.
Is there any other way to check if the sim card of the phone is changed?
Regards
You can use getSimOperatorName() concat to getSimSerialNumber() or getSimSerialNumber() only as phone number alternative.
Is more ease to detect sim changes in this way.

Changing Android Device name in code

I am trying to change the name of the Android Device that my program that is currently running on because the name of the device will contain information that is relevant when it communicates with other phones. The name of the phone will be constantly changed as phone scans for other phones and calculates information. Any ideas on how to change the name of the phone within the java code? I can't image it being more than a few lines of code, but I can't find anything.
Thanks in advance.
It's quite easy, get an instance of the bluetooth adaptor (since the only name you can set is the bluetooth name I think) that refers to the local device and call setName("newName"); on it.
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
myDevice.setName("new name");
Quoting the docs:
Valid Bluetooth names are a maximum of 248 bytes using UTF-8 encoding, although many remote devices can only display the first 40 characters, and some may be limited to just 20.
So be careful with what you set as the device name. Oh, on another note, you can't change the name if the device bluetooth is off. So the actual code after checking it would be something on the lines of the following:
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
if(myDevice.getState() == BluetoothAdapter.STATE_ON){
myDevice.setName("new name");
}
Important to note:
If you are going to test this on an emulator, beware that there are not bluetooth capabilities on the emulators and therefor the getDefaultAdapter() method returns null, resulting in a NullPointerException :)

How can i get both sender and receivers mobile number in Android

I tried finding current mobile no of my app user but in my country the mobile no is not present in SIM so the current API returns null.
As a work around i thought i would just access the outbox of the user to get both senders and receivers no but unfortunately i am getting only receivers no.
Say for example I am user X and I send an SMS to user Y, through telephony API i am only able to get phone no of user Y to whom i am sending the SMS but not of user X.
Can any one suggest any other way i can access the current mobile no of any user??
Thanks
Pranay
Do you think this is what you are looking for? TelephonyManager::getLine1Number
(please, notice you are going to need the "android.permission.READ_PHONE_STATE" permission set in your app manifest.)

Categories

Resources