Rejecting MDM push dictionary because it does not have the right magic string - mdm

I use the apple's mdm and find a strange problem.
This iphone device could have been mdm control, it works fine,but suddenly lost control, see xcode the device log appears, "Rejecting MDM Push dictionary because it does not have the right magic string."
Is this how to solve this?
Aug 1 08:03:04 iPhone6 apsd(PersistentConnection)[93] <Notice>: 2017-08-01 08:03:04 +0800 apsd[93]: <APSCourier: 0x155d12f70>: Received message for enabled topic 'com.apple.mgmt.External.69e3a6a4-4f53' with payload '{
aps = {
};
mdm = "5E73DE3E-ADE2-4955-B58C";
}' onInterface: WWAN for device token: YES with priority (null)
Aug 1 08:03:04 iPhone6 mdmd(libdispatch.dylib)[4508] <Notice>: Push token received.
Aug 1 08:03:04 iPhone6 mdmd(ApplePushService)[4508] <Notice>: Received push notification.
Aug 1 08:03:04 iPhone6 mdmd(ApplePushService)[4508] <Notice>: Rejecting MDM push dictionary because it does not have the right magic string.

Your push magic doesn't seem to be correct it should almost always be in UUID format, double check that you are sending the correct one, or show the code how you're sending it/obtaining it
SOURCE:
https://media.blackhat.com/bh-us-11/Schuetz/BH_US_11_Schuetz_InsideAppleMDM_WP.pdf
The PushMagic token is a hexadecimal string, likely a simple random
UUID (in UUID format).

Related

Bluemix Push REST API messages report details

I'm trying to see why one of my apps is failing at delivering push notifications to iOS devices.
On the Push REST API doc page I saw that there was the GET /apps/{applicationId}/messages/{messageId}/report endpoint which I could use but it seems that there is little information given with that.
As a result to GET https://mobile.eu-gb.bluemix.net/imfpush/v1/apps/2cc73363-b50f-4b60-b2f9-c483ff5cd414/messages/8d58f4e/report I only get
{
"invalid": 2,
"sent": 2,
"ios": {
"invalid": 2,
"sent": 2
}
}
for a push sent to 2 ios device.
Is there a way to get more information on why the push delivery has failed/was invalid? Do you have another endpoint where I can get additional info?
Unfortunately, at this time, there is not a REST API call that will give additional error information. However, if you open a Bluemix Support ticket, we can pull additional error information from the server logs using your AppGUID.
iOS certificate issues are one of the more common of invalid messages in the message report.
#mihavr If the GET MessageID report (https://mobile.eu-gb.bluemix.net/imfpush/v1/apps/2cc73363-b50f-4b60-b2f9-c483ff5cd414/messages/8d58f4e/report) gives you invalid status for IOS device that means the problem seems to have been with push certificate is invalid and that generates invalid token when you register the ios device. Hence send message failed to deliver the message on the device and the messageID report shows Invalid status.
{
"invalid": 2,
"sent": 2,
"ios": {
"invalid": 2,
"sent": 2
}
}

Notification not getting shown in one of IOS device

I am facing problem with notification. Notification is not getting shown in device from last 12 hours. It was working earlier. Sending to other devices works fine.
I checked notification center and other thing. Notification is enabled for app.
After following
http://developer.apple.com/library/ios/#technotes/tn2265/_index.html
I have enabled Enabling Push Status Messages on iOS.
On console , device is printing some information like:
<Error>: kDataAttachStatusNotification sent, wasAttached: 1 isAttached: 1
What does it mean ? Is it getting notification from server side and failing to show and receive due to some reason ?
Edit:
After syncing logs with itunes. Logs says something like:
2013-08-01 10:51:06 +0530 apsd[76]: _getClientIdentity: already had identity: <SecIdentityRef: (some value here)>
wasUp NO isUp NO linkQualityBelowAndWOWAvail: YES wantsInterfaceAssertion YES avoidWWANOnCall NO
2013-08-01 10:51:06 +0530 apsd[76]: _getClientIdentity: already had identity: <SecIdentityRef: (some value here)>
2013-08-01 10:51:06 +0530 apsd[76]: peer(68) received XPC_ERROR_CONNECTION_INVALID
Have you requested permission from the user to present notifications?
Try adding the following code to your AppDelegate's application: didFinishLaunchingWithOptions: method:
Swift:
if (UIApplication.instancesRespondToSelector(Selector("registerUserNotificationSettings:"))) {
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Alert, categories: nil))
}
Objective-C:
if ([application respondsToSelector:#selector(registerUserNotificationSettings:)]) {
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert categories:nil]];
}

error with push notification ios when registring devicetoken

I implement push notification in my application, I check it on my ipad device, in the php file, I put the device token specified:
$deviceToken = '2ca0c25ed7acea73e19c9d9193e57a12c1817ed48ddf8f44baea42e68a51563c';
until now, the notification works fine.
when I want to register devices into database, I got an the below error:
Error in registration. Error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x1edda520 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
I don't understand the mentioned error, Note: that I use push notification for development and not for distribution yet.
I got the code of the registration from this link
Thank you for you help!
Have you registered your application for push notifications in the developer center? And if you have, did you re-generate your provisioning profile? You need to make sure your provisioning profile is setup for push messaging.
As pointed out it is most likely a code-signing problem. Be sure to sign with the correct profile! Check your target and project settings if those are correct and not some kind of wildcard ID.
Also may I point out that the How-To you posted is still using UDID.
UIDevice *dev = [UIDevice currentDevice];
NSString *deviceUuid = dev.uniqueIdentifier;
Push only uses the devToken and UDID use is deprecated.
A solution can be found here
This error is related to certificates..Make sure you set your certificate name is correct in php file and it is present in your respective folder. Let me know if you have still error.
As a request,I am posting code of php file which is used to send notification :
<?php
// Adjust to your timezone
date_default_timezone_set('Asia/Calcutta');
// Report all PHP errors
error_reporting(-1);
// Using Autoload all classes are loaded on-demand
require_once 'ApnsPHP/Autoload.php';
// Instantiate a new ApnsPHP_Push object
$push = new ApnsPHP_Push(
ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
'ck.pem'
);
// Set the Provider Certificate passphrase
$push->setProviderCertificatePassphrase('PUT_HERE_YOUR_PASSPHRASE_WHILE_GENERATING_NOTIFICATION');
// Set the Root Certificate Autority to verify the Apple remote peer
$push->setRootCertificationAuthority('ck.pem');
// Connect to the Apple Push Notification Service
$push->connect();
// Instantiate a new Message with a single recipient
$message = new ApnsPHP_Message('PUT_HERE_DEVICE_TOKEN');
// Set a custom identifier. To get back this identifier use the getCustomIdentifier() method
// over a ApnsPHP_Message object retrieved with the getErrors() message.
$message->setCustomIdentifier("Message-Badge-3");
// Set badge icon to "1"
$message->setBadge(1);
// Set a simple welcome text
$message->setText('Hello APNs-enabled device!');
// Play the default sound
$message->setSound();
// Set a custom property
$message->setCustomProperty('acme2', array('bang', 'whiz'));
// Set another custom property
$message->setCustomProperty('acme3', array('bing', 'bong'));
// Set the expiry value to 30 seconds
$message->setExpiry(30);
// Add the message to the message queue
$push->add($message);
// Send all messages in the message queue
$push->send();
// Disconnect from the Apple Push Notification Service
$push->disconnect();
// Examine the error message container
$aErrorQueue = $push->getErrors();
if (!empty($aErrorQueue)) {
var_dump($aErrorQueue);
}
?>
This code of notification is of APNS library.You can see here : APNS_PHP

Not sending turn with GKTurnBasedParticipant IOS 5 iphone

I am developing an app for iPad and iPhone with the Game Center Feature. The game is sending correctly one participant turns from iPad 2 IOS 6, but when I try to send the turn to another participant from an iPhone 4 IOS 5 the following error appears:
<GKTurnBasedParticipant 3d8e50 - id:(null) status:Matching outcome:None lastTurn:(null)>
2013-03-14 23:56:22.030 [453:707] ERROR::::::Error Domain=GKErrorDomain Code=3 "The requested operation could not be completed due to an error communicating with the server." UserInfo=0x7a81170 {NSUnderlyingError=0x3f4220 "The operation couldn’t be completed. status = 5008, missing required key: turns", NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server.}
2013-03-14 23:56:22.031 [453:707] Oops, there was a problem. Try that again.
I am using the following method that works perfectly on IOS 6:
[currentMatch endTurnWithNextParticipant:nextParticipant
matchData:data completionHandler:^(NSError *error) {
if (error) {
NSLog(#"%#", error);
NSLog(
#"Oops, there was a problem. Try that again.");
} else {
NSLog(#"Your turn is over.");
}
}];
The error number 3 is GKErrorCommunicationsFailure,but I cant understand what it is going on!
I logged on correctly when the app starts with the Game Center
This error will always come when you are working on Simulator instead of device, but sometimes it pops out on device, because of Push Notification Failure,
Please check if you device is receiving Push Notifications.
UPDATED
I recently figured it out that Game Center does not send push notifications to devices which does not have sim card inserted

Apple Push Notification is not delivered

I know it's a little bit flooded with Apple's Push Notification Service (APNs) issues all over StackOverflow so I actually did a lot of researches before coming up my question.
Basically, I have followed the apns-php's CertificateCreation, some tutorial like on mobiforge, and some from Matthijs Hollemans. Still, I can't get any notification posted onto my iPad 2.
Basically these are the steps I have done:
I followed the CertificateCreation tutorial, I came out with server_certificates_bundle_sandbox.pem, entrust_root_certification_authority.pem.
Followed the tutorial specified in mobiforge blog, I successfully created the App ID, provisioning profile and linked them together nicely.
Description: APNTest
Bundle Seed ID: Use Team ID
Bundle Identifier: com.learn.APN
Then I enable the Development Push SSL Certificate (only for now) using the same certificate request I have used just now to get the certs, and I download it and install it into my keychain.
I downloaded my provisioning profile in .mobileprovision file and loaded it into Xcode's Organizer under my iPad 2 device.
Next I create a simple application with only these codes:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
// Override point for customization after application launch.
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(#"%#", deviceToken);
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(#"Error: %#", error);
}
Then I configure the build parameters:
Targets > Info > Build Identifier: net.learn.APN
Targets > Build Settings > Code Signing Identity > (I chose the provisioning profile I have installed just now, and it automatically selects the identical profiles for my Debug and Release)
I build and run the application on my iPad 2. My application requesting for Push Notification and after I approved it, the Token ID appeared in my console:
2012-01-19 12:43:26.345 TestAPN[578:707] <3cb08612 9392996b 5332d2fc 5adce03d 994f8959 d7a2ac38 de7bed52 c8e0778e>
I used apns-php, changed the device ID (raw 64 hexa-values), then run the sample_push.php. Script ran successfully, but my device is not receiving any notification
Then I try to use the SimplePush.php. A "Message successfully delivered" appeared, but my iPad still doesn't receive any notification from APN
Question is, which steps have I done wrongly? I'm pretty newbie in this area, and it is actually a requirement for my project that the server need to send out messages to our own applications. We are aware of the third party softwares that send APN on behalf of you, but we would like to implement one ourselves.
I also came across the "APN Feedback Service" and I written this (base on the SimplePush) but sadly it's empty. What should I do now?
<?php
// Put your private key's passphrase here:
$passphrase = '';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'server_certificates_bundle_sandbox.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$fp = stream_socket_client(
'ssl://feedback.sandbox.push.apple.com:2196', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
while (!feof($fp)) {
$data = fgets($fp, 1024);
var_dump(unpack("N1timestamp/n1length/H*devtoken", $data));
}
// Close the connection to the server
fclose($fp);
Note
I am aware of the differences between development/production certs.
iPad is not jailbroken, running iOS 5.0.1
Other App Store apps receives notifications normally
XCode 4.2.1, Lion 10.7.2
I hope I'm not duplicates any of the questions here.. ;)
EDIT
When I run php simplepush.php then php feedback.php, I received a feedback with my device ID. My App is still in the iPad, so does it mean my device ID is wrong?
[root#ip-xx-xx-xx-xx SimplePush]# php feedback.php
Connected to APNS
array(3) {
["timestamp"]=>
int(1326962028)
["length"]=>
int(32)
["devtoken"]=>
string(64) "3cb086129392996b5332d2fc5adce03d994f8959d7a2ac38de7bed52c8e0778e"
}
Thanks
EDIT
After much struggling and redoing all the steps written by Matthijs Hollemans, I finally get it working. So the problem lies within the incorrect PEM file generated... hmm
I had similar problem, for me the key thing I didn't know is that the device token is different for dev and prod (for the same device).
I was using the device token I got when testing in dev to test in prod. This was working fine in dev, but when I switched to prod I kept the same device token in my python script (assuming, wrongfully, that the device token would be the same for the same device) but the actual device token registered in prod was different.
In practice this wouldn't happen as the device token is sent to the server, but when I was testing I was using hard coded device token as I didn't want to involve the server.
Hopefully this will save someone some frustration.