React-Native: Day by Day


Welcome to AppEngineer
We are come back with some exiting tutorial on React-native for iOS.

Why Choose React Native
At this point, you might think that React Native is another “write once, run anywhere” framework, like Titanium or PhoneGap, but you would be wrong. As Facebook very clearly states on their blog post, they acknowledge the differences between platforms, so instead, their goal is to bring the paradigms of React, which is very successful on the web, to native, while having the same set of engineers working on whatever platform they choose. They call this approach “learn once, write everywhere”.

How React Native actually works is by embedding the JavaScript files in the app, and running them locally. But also, one could have these files remotely on a server fetching their latest version when the app has connectivity. This would allow updating an application very rapidly, without having to go through the app store’s review process. There are also third party services that offer such solutions, and using them potentially could mean that for smaller applications that don’t have a lot of data to display (e.g. festival apps), a backend isn’t needed anymore.

Most of the coding is based on JavaScript and the paradigms in React. Thus, it makes more sense that a typical team working on a React Native application is composed mostly of JavaScript engineers, because ideally those will be already familiar with the tools and paradigms used by this framework: React, EcmaScript, Redux and Flex layout.

Advantages:
1. Learn once, write everywhere
2. Hot Reloading
3. Able to interact with Nativ code
4. Able to create libary that can used in both iOS and Android.
5. Save development cost (Up to 30%)
Limitations
1. Lack proper documentions
2. lack of developer community
3. Native SDK update
4. Uncertain roadmap

We are committed for Day by Day React-Native tutorial. You will get our first tutorial very soon.

Advertisements

How to compress video in iOS


Hey I am here to introduce video compression in iOS . Sometime we need to compress capture video before uploading it to server.

– (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL

                                   outputURL:(NSURL*)outputURL

                                     handler:(void (^)(AVAssetExportSession*))handler

{

    [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];

    AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:inputURL options:nil];

    AVAssetExportSession *session = [[AVAssetExportSession alloc] initWithAsset: urlAsset presetName:AVAssetExportPresetLowQuality];

    CMTime startTime = CMTimeMake(0, 1);

    //CMTime stopTime = urlAsset.duration;

    CMTime stopTime = CMTimeMake(urlAsset.duration.value, 1);

    CMTimeRange exportTimeRange = CMTimeRangeFromTimeToTime(startTime, stopTime);

  session.outputURL = outputURL;

    //session.outputFileType = AVFileTypeQuickTimeMovie;

    session.outputFileType =AVFileTypeMPEG4;

    session.timeRange = exportTimeRange;

    [session exportAsynchronouslyWithCompletionHandler:^(void)

     {

  handler(session);

  }];

}

Call this as following

NSURL *uploadURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingString:@”msy.mp4″]];

[self convertVideoToLowQuailtyWithInputURL:[rep url] outputURL:uploadURL handler:^(AVAssetExportSession *session)

                          {

                              if (session.status == AVAssetExportSessionStatusCompleted)

                              {

              NSString *path = [uploadURL path];

               NSData *data = [[NSFileManager defaultManager] contentsAtPath:path];

               NSLog(@”size after compress video is %lu”,(unsigned long)data);                                                     [[NSOperationQueue mainQueue] addOperationWithBlock:^{

                        // put your code

                  }];

    }  else{

                   NSLog(@”error on compressing……..”);

                 }

     }];

Thanks .