Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.2 kB
2
Indexable
Never

@property(nonatomic, retain) IBOutlet NSString* titleCover;
@property(nonatomic, retain) IBOutlet NSString* imgCoverLink;


    NSArray * arr = [dict getArray:@"CoverPictures"];
    NSLog(@"%@",arr.firstObject);

    header.titleCover = [dict getString:@"Title"];
    header.imgCoverLink = arr.firstObject;





[self createDLink:linkNew :self.titleCover :self.imgCoverLink withCompletionHandler:^(NSString *linkStr) {
        NSURL *linkURL = [NSURL URLWithString:linkStr];
        NSArray *objectsToShare = @[linkURL];
        
        UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
        
//        NSArray *excludeActivities = @[UIActivityTypeAirDrop,
//                                       UIActivityTypePrint,
//                                       UIActivityTypeAssignToContact,
//                                       UIActivityTypeSaveToCameraRoll,
//                                       UIActivityTypeAddToReadingList,
//                                       UIActivityTypePostToFlickr,
//                                       UIActivityTypePostToVimeo];
//
//        activityVC.excludedActivityTypes = excludeActivities;
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:activityVC animated:true completion:nil];
        });
        
    }];









-(void)createDLink:(NSString*)linkStr:(NSString*)linkTitle:(NSString*)linkImage withCompletionHandler:(void (^)(NSString*))completionHandler{
    
    NSURL *link = [NSURL URLWithString:linkStr];
    [FIRDynamicLinks performDiagnosticsWithCompletion:nil];
    NSLog(@"----------");
    //FIRDynamicLinkComponents *components = [FIRDynamicLinkComponents componentsWithLink:link domain:@"scankapps.page.link"];
    FIRDynamicLinkComponents *components = [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:@"https://scank.page.link"];//@"https://scank.page.link"@"https://scankapps.page.link" //@"scankapps.page.link"
    FIRDynamicLinkComponentsOptions *options = [FIRDynamicLinkComponentsOptions options];
    options.pathLength = FIRShortDynamicLinkPathLengthShort;
    
    FIRDynamicLinkIOSParameters *iOSParams = [FIRDynamicLinkIOSParameters parametersWithBundleID:@"com.app.EAR"];//@"com.smartapps.scank"//@"com.app.EAR"
    FIRDynamicLinkSocialMetaTagParameters* socialParam = [[FIRDynamicLinkSocialMetaTagParameters alloc]init];
    
    socialParam.title = linkTitle;
    socialParam.imageURL = [NSURL URLWithString:linkImage];
    components.socialMetaTagParameters = socialParam;

    iOSParams.customScheme = @"scank";//@"scank://";
     //iOSParams.appStoreID = @"1433961754";
    components.iOSParameters = iOSParams;
    components.options = options;

    [components shortenWithCompletion:^(NSURL *_Nullable shortURL,
                                        NSArray *_Nullable warnings,
                                        NSError *_Nullable error) {
        completionHandler(shortURL.absoluteString);
        if (error || shortURL == nil) { return; }
        NSLog(@"The short URL is: %@", shortURL);
    }];
}