You have two questions here:
The app should scan for other devices running the app (in background)
The answer here is NO - MPC does not work in the background (see this so response)
For your second question:
is it possible to connect to other devices using multipeer but without having to show the alert
The answer is Yes .. all the detail you need can be found in the apple docs. Here's some snippets on what I do:
On one device - start the browser
_serviceBrowser = [[MCNearbyServiceBrowser alloc] initWithPeer:_peerID
serviceType:_sessionName];
[_serviceBrowser startBrowsingForPeers];
On the other device - start the advertiser
_serviceAdvertiser = [[MCNearbyServiceAdvertiser alloc] initWithPeer:_peerID
discoveryInfo:nil
serviceType:_sessionName];
[_serviceAdvertiser startAdvertisingPeer];
These services implement delegate functions to advise your app of a possible connection. Here the browser is advised of an advertiser and now invites the peer to join in a session
- (void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info
{
[browser invitePeer:peerID toSession:_session withContext:nil timeout:30.0];
}
The advertiser then responds
- (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer: (MCPeerID *)peerID withContext:(NSData *)context invitationHandler:(void(^)(BOOL accept, MCSession *session))invitationHandler
{
invitationHandler(YES, _session);
}
Now you will receive a session delegate call to advise you of the state of your peer connectivity. At this point you should be connected - no "real" user interaction required.
- (void)session:(MCSession *)session peer:(MCPeerID *)peerID didChangeState:(MCSessionState)state