2017.03.14

Later not to do the title party, feel now more and more technical article title diaobaotian, empty content without dry goods, even a lot of official documents to pick up, but also not all, it is rubbish. Although I can not write a great article, but I will not be the kind of person I oppose at least.

First, say something useless

  • One of the ten principles of economics is that people respond to incentives. This principle states that people make decisions by comparing costs and benefits, and when benefits and costs change, people’s behavior will also change
  • A brief introduction to the economy of word of mouth is the Internet era. Because the cost of communication is greatly reduced, products so good that users can not help Posting moments can win a large number of media almost free, obtain huge traffic, and improve the conversion rate of business phenomenon (from Liu Run Teacher Five Minutes Business School).
  • In general, there are three ways a user first learns about a product
    • Paid media: newspaper advertisements, sponsored television programs, etc
    • Own media: official blog, official account, official website, etc
    • Win media: The best form of media is the spontaneous communication that you don’t own, but don’t pay for

So why is the word of mouth economy the best form of communication? Analysis is made from two aspects of users’ requirements:

  • Psychological demand: Users are often skeptical of a strange product. Through confirmation with surrounding friends, the sense of trust between friends can bring psychological security to their consumption behavior
  • Social needs: when friends are discussing a certain product, they will enhance their sense of presence and identity in the circle through the sense of participation in using the product

2. How can users be stimulated to share independently to the maximum extent

In addition to practicing internal skills (excellent products), some tricks (appropriate reward mechanisms) can also motivate users to share to a certain extent. Let’s take a few examples from other industries to illustrate the problem:

  • Some of the 46 and 6 training classes in the students after the certificate (for male students), invited a Taobao model, dressed in the United States to give them a certificate to take a photo, the results of those students’ circle of friends are not spared advertising
  • Gym membership also gives the introducer a few classes
  • A lot of restaurants opening 70% off, the condition is to take store photos to send circle of friends, with the circle of friends screenshots enjoy discounts

The incentive measures must be based on good products, like: your goddess has a crush on you, you sell cute, she agreed to be your girlfriend; If a girl doesn’t like you, playing cute will just make her think you’re ugly and will act weird

Second, product perspective

1. What are the main forms of rewards?
  • Material incentives

  • Physical objects: such as the forwarding lottery for iPhone promoted by Weibo

  • Virtual goods: coupons and top-up cards provided by didi, Ofo and other transportation sharing platforms

  • spiritual

  • Presence: likes, comments, attention, etc., the most straightforward such as weibo, post bar, etc

  • Honors: early QQ rank, Ranking of Alipay members, KEEP, various titles and MEDALS obtained by APP, ranking of wechat sports

  • Rights: The higher the membership level of JD platform, the lower the lowest price of free shipping

2. Main interface of this function
  • For example, enter the H5 page of the “Recommended prize” activity from the banner page, which generally includes
    • My achievements: Shows how many people have been invited and how many awards have been received
    • Reward rules button: Click to enter the detailed recommended activity reward rules
    • Sharing channels generally include the following three:
    • Share to wechat, QQ, Weibo and other third-party platforms
    • Qr code (click to pop up the QR code for sharing in person)
    • Copy short links (considering related forums or other chat sharing)
  • You can also add a “Details” button in the navigation bar, and click it to enter the invitation details interface, which friends are invited and which rewards are obtained in detail
  • A middle page that is shared. The sharer first sees the active page and then clicks the download button on the active page.
    • Users who have installed the app will directly open the content page in the app after clicking the share link
    • Users without an app are automatically redirected to the app Store when they click on the link.
3, the product must understand the technology
  • Use LinkedMe technology to create a short link that is unique to each of your recommended users and then share it. Users who download from this link will get a match, and both users will receive a reward. No invitation code is required
  • You can customize various parameters in exclusive links, such as the recommender’s userId, sharing platform, sharing time, etc
  • After the invited user triggers the deep link, LinkedME deep link automatically determines whether the App is installed
    • If you decide to install the App, directly open the content page corresponding to the deep link of the App.
    • If the app store is not installed, go to the default app store, download and install the app, and go to the content page after registration and login.

Third, technical implementation ideas

#####1. Main methods of linkedMe

  • The official demo of linkedMe is clear, and the integration document is relatively clear. During the integration, pay attention to the prefix when adding the key value to the plist file. The document does not emphasize this, but the screenshot given is directly added the prefix of “linkedme_live_”
  • Methods to generate short links
// Because several sharing platforms are involved, encapsulate a method for generating short links
// After the short link is generated, the corresponding operation is performed, so
- (void)createShotrUrlWithChannel:(NSString *)channel Success:(void (^)())block_success
                          failure:(void (^)())block_failure {
    LMUniversalObject *LMObj = [[LMUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
    LMObj.title = @ "";/ / title
    LMObj.canonicalUrl = @"http://";
    LMObj.contentDescription = @" Plapla Recommended Campaign";
    LMObj.imageUrl = @"http://yourActivityImageUrl";
    
# Warning there are two ways to add a parameter, which must be the same as android, because it involves sharing downloads on both platforms
    // Add parameters in method 1
// [LMObj addMetadataKey:@"linkedMe_appid" value:@"appidNum"];
// [LMObj addMetadataKey:@"linkedMe_udid" value:@"user_udid"];
// [LMObj addMetadataKey:@"platform" value:channel];
//    
    NSString *dateDescription = [[NSDate date] description];
// [LMObj addMetadataKey:@"linkedMe_time" value:dateDescription];
// [LMObj addMetadataKey:@"linkedMe_user" value:validId];
    
    self.linkedUniversalObject = LMObj;
    
    LMLinkProperties *linkProperties = [[LMLinkProperties alloc] init];
    linkProperties.channel = channel;// Channels (wechat, Weibo,QQ, etc...)
    linkProperties.feature = @"Share";// Represents the features of deep links, such as invites, shares, etc.
    linkProperties.tags=@[@"LinkedME".@"Demo"];// Indicate the deep link tag feature, customize any value;
    linkProperties.stage = @"Live";// Represents phase features of deep links, such as first release, second release testing, etc.
    linkProperties.source = @"iOS";
    
    // Add parameters in method 2
    [linkProperties addControlParam:@"linkedMe_appid" withValue:AppID];/ / the Demo
    [linkProperties addControlParam:@"linkedMe_udid" withValue:UDID];
    [linkProperties addControlParam:@"platform" withValue:channel];
    [linkProperties addControlParam:@"linkedMe_time" withValue:dateDescription];
    [linkProperties addControlParam:@"linkedMe_user" withValue:validId];
    [linkProperties setAndroidPathControlParam:@ "*"];
    [linkProperties setIOSKeyControlParam:@ "*"];
    
    parmas = [NSString stringWithFormat:@"%@\n%@"[self.linkedUniversalObject description],[linkProperties description]];
    // Start requesting short chains
    [self.linkedUniversalObject getShortUrlWithLinkProperties:linkProperties andCallback:^(NSString *url, NSError *err) {
        if (url) {
            NSLog(@"[LinkedME Info] SDK creates the url is:%@", url);

            // h5 middle page splice short link
            self.shortUrl = [NSString stringWithFormat:@ % @ "? download=%@".@" Middle page URL", url];
            if(block_success) { block_success(); }}else {
            if (block_failure) {
                block_failure();
            }
            self.shortUrl = H5_LIVE_URL; }}]; }Copy the code
  • Since active pages typically use H5 pages, the way the call generates short links is also done by JS calls
- (void)js2oc_recommend:(NSDictionary *)dict {
    NSString *platform = dict[@"linkedMePlatform"];
    / / define the block
    void (^recommendBlock)();
    
    if ([platform isEqualToString:@"wechat"]) { // Share with wechat
        recommendBlock = ^(){
            [self shareAppToWeChatSession];
        };
    } else if ([platform isEqualToString:@"moments"]) { // Share it on moments
        recommendBlock = ^(){
            [self shareAppToWeChatTimeline];
        };
    } else if ([platform isEqualToString:@"weibo"]) { // Share to weibo
        recommendBlock = ^(){
            [self shareAppToSina];
        };
    } else if ([platform isEqualToString:@"qq"]) { // Share to QQ
        recommendBlock = ^(){
            [self shareAppToQQSession];
        };
    } else if ([platform isEqualToString:@"qzone"]) { // Share to qzone
        recommendBlock = ^(){
            [self shareAppToQzone];
        };
    } else if ([platform isEqualToString:@"qrcode"]) { // Generate a QR code
        recommendBlock = ^(){
            [self showQRImageWithString:self.shortUrl];
        };
    } else if ([platform isEqualToString:@"copy"]) { / / copy
        recommendBlock = ^(){
            // Here is a copy of "advertising slogan + short link", convenient forum, etc paste
            // Here we use the Sina API to join the short link in the middle page +linkedMe to make the link shorter and more user-friendly. The specific code is not sticky
# Warning can also be implemented using LInkedMe's recommended JS method to generate short links again
            UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
            pasteboard.string = [NSString stringWithFormat:Activity copy la la la la %@.self.shortURL];
            [MBProgressHUD showSuccess:@" Copy succeeded"];
        };
    }
    [self createShotrUrlWithChannel:platform Success:recommendBlock failure:^{
        [MBProgressHUD showMessage:"Sharing failed, please check the network"];
    }];
}
Copy the code
  • There are a few methods that need to be pasted in the AppDelegate. Here’s how the recommended user opens the app after downloading the app for the first time: After you click the download button on the shared middle page, and then you get into the appStore and download, you need to do a little detection interception in the didFinishLaunching method

The official SDK of LinkedMe will automatically make a cache. For example, after the user triggers the deep link, the app is not connected to the network for the first time, and it will still take effect when the app is opened for the second time (with network status)

- (void)checkoutLinkedMeWithOptions:(NSDictionary *)launchOptions {

// Initialize and instantiate

    LinkedME* linkedme = [LinkedME getInstance];

    

// Prints logs

    //    [linkedme setDebug];

    

// Get the jump parameter

    [linkedme initSessionWithLaunchOptions:launchOptions automaticallyDisplayDeepLinkController:NO deepLinkHandler:^(NSDictionary* params, NSError* error) {

if (! error) {

// Try catch is always used to prevent App crashes due to error in passing parameters

            @try {

                NSLog(@"LinkedME finished init with params = %@",[params description]);

// Get details page type (e.g. news client, image type, video type, text type, etc.)

                //            NSString *title = [params objectForKey:@"$og_title"];

                NSString *tag = params[@"$control"][@"share_udid"];

                

                if (tag.length >0) {

// Interface 1: Reports information to the server, indicating that the user has downloaded the APP

                    [self reportLinkedMeInfoWithPara:params];

                }

            } @catch (NSException *exception) {

                NSLog(@"exception-->%@", exception);

            } @finally {

                

            }

        } else {

            NSLog(@"LinkedME failed init: %@", error);

        }

    }];

}

Copy the code
2. Interface design
  • The first interface has been mentioned above: when the recommended user opens the APP for the first time, he/she needs to report the appId, UDID and userId of the active sharing user he/she has obtained to the server.
  • The second interface is the API to get the number of rewards. By passing the parameter, you can get the reward information as recommender and recommender
  • The third interface is the API for claiming rewards (recommended users need to register successfully before claiming rewards), which is automatically called when the number of rewards returned is greater than zero
3. Keychain changes in iOS 10.3
  • If the App is deleted, the data stored in the keychain is also deleted
  • If a keychain group is used, data in the keychain is deleted when all apps related to the group are deleted

This change, while not officially announced by Apple, has been confirmed by Apple employees in a forum post, which reads as follows: This is an intentional change in iOS 10.3 to protect user privacy. Information that can identify a user should not be Left on the device after the app that created it has been removed. It has never been a part of the API contract that keychain items created by an app would survive when the app is removed. This has always been an implementation detail. If a keychain item is shared with other apps, it won’t be deleted until those other apps have been deleted as well.

  • When I heard the news, my little friend and I cried and fainted in the toilet:

    This means that we can no longer trace the uniqueness of the device based on the device number, and sure enough, the agreement was not signed in vain

    After three hours of thinking about it, when I can’t think of anything else to do with my career change, I smile and embrace it

  • Later, I studied the direct login of Zhihu, Weibo and other apps after reinstallation. Instead of using simple keyChain, I used SFSafariViewController launched by iOS9, which can store passwords, shared cookies, iCloud Web form data, certificates and other data in the system. Bind the iCloud keyChain. Thanks to iOS9, thanks to SFSafariViewController! Linkedin also uses the technology, and it’s pretty straightforward

  • In beta 2 to Beta 5 of iOS 10.3, keychain data will be deleted due to APP deletion, but after beta 6 of iOS 10.3, keychain will continue to be used. Click for more information

4. Finally, the following pits have been stepped on, please bypass them directly
  • Weibo is whitelisted so that only apps that advertise can be directly accessed by the App Store. Others go to a middle page and click download again
  • When the PList file sets the LinkedMe ID, you need to prefix it
  • Considering SSO logins, SNS logins, free logins for new users, direct logins for old users, token expiration, etc., it is best to put the method of detecting linkedMe deep links later, such as after entering the main screen
  • There are two ways to add parameters, android and iOS should be corresponding. In demo, Android does not set viewId by default, but iOS has a default unique identifier, which needs to be unified
  • LinkedMe has problems, QQ app Bao will add problems
  • Caching does not need to be done, LinkedMe is already done internally, there is no network this time, the request will continue next time