When install build from xcode push notification is working but when install ipa it is not working

前端 未结 5 723
梦毁少年i
梦毁少年i 2021-01-19 03:39

I implemented push notification in my app and it is working when i install build from xcode but not working when i install app via a link generated by diawi.com why this is

5条回答
  •  粉色の甜心
    2021-01-19 03:58

    As @sadiqxs notice there are two types of certs, and in a comment you can find excelent simplePush code (http://d1xzuxjlafny7l.cloudfront.net/downloads/SimplePush.zip).

    BUT one often forgotten thing!

    Your deviceToken changed (!!!) while you compile to production (ad-hoc) and deploy from Xcode. What i suggest you to do is:

    1. Create both developer and production certificate in developer center (what you already have)
    2. Download this simple push app
    3. Read your deviceToken for development env and check if it's working
    4. NSLog the token in method: -(void)application:didRegisterForRemoteNotificationsWithDeviceToken:

    sample:

    - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
        NSString *dt = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
        dt = [dt stringByReplacingOccurrencesOfString:@" " withString:@""];
        NSLog(@"%@",dt");
    }
    
    1. Check out the device log and read the production token
    2. Try with simple push if push got to device

    6a) If yes, problem solved

    6b) If no, and you receive the push for dev env for sure you have an issue with certificates and regenerate them

    While you using SimplePush script remember to change url to production (gateway.push.apple.com) from sandbox one.

提交回复
热议问题