Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Created January 16, 2016 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhrrgn/e1611a6a26586b5a2e66 to your computer and use it in GitHub Desktop.
Save dhrrgn/e1611a6a26586b5a2e66 to your computer and use it in GitHub Desktop.
//
// RNUtils.m
//
// Created by Dan Horrigan on 8/13/15.
// Copyright (c) 2015 Tackk, Inc. All rights reserved.
//
#import "RCTBridgeModule.h"
@interface RNUtils : NSObject <RCTBridgeModule>
@end
// ---------------
@implementation RNUtils
@synthesize bridge = _bridge;
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(reload)
{
[_bridge reload];
}
RCT_EXPORT_METHOD(getCurrentLocale:(RCTResponseSenderBlock)callback)
{
NSLocale *locale = [NSLocale currentLocale];
NSDictionary *localeDict = @{
@"Identifier": [locale objectForKey:NSLocaleIdentifier],
@"LanguageCode": [locale objectForKey:NSLocaleLanguageCode],
@"CountryCode": [locale objectForKey:NSLocaleCountryCode],
@"UsesMetricSystem": [locale objectForKey:NSLocaleUsesMetricSystem],
@"DecimalSeparator": [locale objectForKey:NSLocaleDecimalSeparator],
@"GroupingSeparator": [locale objectForKey:NSLocaleGroupingSeparator],
@"CurrencySymbol": [locale objectForKey:NSLocaleCurrencySymbol],
@"CurrencyCode": [locale objectForKey:NSLocaleCurrencyCode],
};
callback(@[localeDict]);
}
- (NSDictionary *)constantsToExport
{
return @{
@"AppVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
@"AppBuild": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
@"SettingsUrl": UIApplicationOpenSettingsURLString,
@"TemporaryDirectory": [NSTemporaryDirectory() stringByStandardizingPath],
};
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment