Send data from device to device - ios

I'm working on local simple chat app for my small company that sends messages from device to device.
Each device is assigned a unique number (for example, 111,112,113, ...).
I need a way to send a message from device (111) to device (112) directly.
I used Push notification, it worked fine, but Notification Settings has to be enabled for the app.
Is there an alternative way to send date from device to device directly?

One option is to use Bluetooth communication via GameKit. Here's the code for a simple chat application using that approach. The example is a few years old but is still relevant:
http://www.devx.com/wireless/Article/43502

Related

Push Notifications without APNS

I work perfectly with Push Notifications for iOS using APNS. So for some customers, I need an on-premise or local solution, where I could send notifications to the device without APNS and without dependence on the internet. Somebody knows? can you help me?
Not possible. You cannot get notification from APNS without internet.
What you can do to accomplish this is you send message from your server to the app while it is in background mode and generate local notification accordingly.
Let me clarify your question.
"Locally" means: you got either no internet connection, a local network without connection to APNS OR the users simply did not register for push notifications.
1. iBeacon with Local Push Notification
So, here is an alternative, and that's kind of NOT what it is basically used for, but as you may know. iBeacons can be used to transport small data chunks, very very small ones. If your users did enable location services, you could include these for your application to trigger certain events (in this case, a very small notification that users came into range of a point of interest).
Downside: The application bundle requires either a static "notification text" to beacon mapping or you have to dynamically download the mapping from a web source, so you could update the notification's text.
2. Bluetooth with Local Push Notification
Another alternative would be to use bluetooth instead.
Devices could auto connect to your Bluetooth Station "Peripheral" - These devices now (with the help of your app) would register to a broadcasting characteristic of your Peripheral.
The peripheral could send messages to the registered devices.
If now the device does receive such a broadcasted message, you could perform a local push. - Without any network connection, just with the help of bluetooth, which itself also requires user permissions, of course.
3. Internet Connection / Silent Push with Local Push Notification
If your application of course had a working internet connection, you could avoid the APNS from Apple and send your own notifications to the device as silent push notifications.
As of iOS 14 this is available through Local Push Connectivity, but you will require the App Push Provider entitlement that you must apply for specifying why you are unable to use APNS.
Apple sample code is available here.
APNS works only with internet. If you need to push a message to the user without internet one solution (probably only solution currently) is using SMS api. But that requires user mobile number. Using URL Schema the user can open your app from the SMS message.

How does the push notification works in the Mobile Device Management in iOS?

I am doing MDM implementation in iOS and I have one server for its implementation.I have gone through the documents and understood the process that we have to undergo.But Simply I don’t understand how it will happen.I have one server and one device.I have my PEM file enrolled in the server.
As the process of MDM says server sends push notification through the device and the information that is present in the message in only the identifying token.Then device is connected to the server and sends an idle message confirming that device is ready for the commands.
My question is how device receives the push notification.If app is in back ground state and it gets a notification to connect to the server is there any method to detect it and send the feedback or is it happening automatically or we have to write some code for it. Also how does the plist (that we get in command) make changes in the settings (unlock to lock) .Do we save it somewhere in the device configuration?
I have got a lot of questions about the command format but did not get anything how the command works.May be I am missing basic iOS coding.please just explain me the above format.
how device receives the push notification.If app is in back ground state and it gets a notification to connect to the server
First of all, you will have to implement server side only for iOS MDM. Client side is implemented by Apple and MDM client is baked into iOS.
As part of OS it dosn't have restriction which usual iOS apps has. It has a persistent channel to APNS and as soon as somebody send a push notification to APNS, the device will receive it through this persistent channel and will start doing what it should be doing.
Also how does the plist (that we get in command) make changes in the settings (unlock to lock) >.Do we save it somewhere in the device configuration?
The answer is the same. You don't have to implement anything on the iOS side. It's all done by Apple- MDM client will get the command, parse it, save it to appropriate places and enforce appropriate policies.

iOS send request directly to APNS without server

On Android, to send a notification all you need to know is GCM id of a device you want to notify. Assuming my user knows the id of another user, he sends a message directly to GCM server, what decreases the load on my server. I don't have experience building iOS apps, so I want to know if the same approach is possible for iOS devices. If my user knows id of another apple device, can he send a request directly to APNS?
Sending a push is just a matter of posting data to apple servers.
You can do it from your server or the device. It's up to you.
Try NWPusher. It contains an iOS demo application that shows how to send push notifications from iOS to iOS.

Locked iOS device scanning for BTLE devices

Can an iOS device scan for presence of Bluetooth LE devices while locked and then respond to them by opening the app?
The scanning can definitely happen in the background.
In order to get the functionality that you're talking about the comment by owen is correct. I'll expand on it a bit.
What we do is when we recognize a BLE device that we're interested in and would like the app to open we send information to our server, from where we have the option to send a push notification if the user wants. This could probably also be achieved with a local notification set a few moments in the future. From there the standard rules apply for push notifications, if they opt to look at it your app can be opened and you can respond to the proximity of the BLE device that initially triggered. The user always has the option to ignore the notification though.

How should I send push notifications only to active devices?

I have an iOS app with a Rails backend (and frontend). I am using Parse for push notifications.
I am trying to figure out the best way to only send push notifications that will be received; that is, I want to avoid sending them to:
Users who only use the web app and don't have the iOS app
Users who had the iOS app but then uninstalled it
The way that the Parse Push API works is that I can broadcast a notification on a certain channel, and any device that is listening to that channel will receive the notifications. Therefore, I am planning to make separate channels for each user.
Obviously, I am going to need to store some sort of information on the server side about who is running the iOS app. I'm curious as to whether anyone out there has experience solving a problem like this and can offer any wisdom. Thanks!
Parse already stores information about who is running iOS and Android apps. Check out the Data Browser, there is an Installation table with a deviceType field.
Have the iOS app register a unique (per-user) channel. If you're only sending push notifications on user channels, it will only be sent to users who have installed the iOS app.
There's not much you can do for users who had the iOS app but uninstalled it. Apple doesn't provide a way for applications to run any code before being uninstalled, so you can't unregister the device with Parse. I'm not sure if Parse does this, but Urban Airship polls the APNS servers and removes devices that have had the app uninstalled after a certain amount of days.

Resources