Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all 17221 articles
Browse latest View live

How to make React Native's ScrollView initial zoom to not be 1?

$
0
0

I want to put content (multiple images vertically arranged) in a React Native ScrollView (iOS only for now, Android will come later) that is bigger than the phone's screen, and start zoomed out so that it is all visible at the same time.

Are there any good examples of using ScrollView.scrollResponderZoomTo in a componentDidMount call that zooms out to fit content in the screen, something like

<ScrollView
  style={{width: 500, height: 1000}}
  // + whatever other properties make this work required way
>
  <View style={{width: 2000, height: 5000}}>
    <Image style={{width: 2000, height: 2000}} source={.....}/>
    <Image style={{width: 2000, height: 3000}} source={.....}/>
  </View>
</ScrollView>

I tried setting the 'zoomScale' property, but that seems to be ignored and always uses the value 1.

According to this issue (https://github.com/facebook/react-native/issues/2176) there is a scrollResponderZoomTo function that can be used, but when I try to use it, it seems that no matter what values I give it it zooms out much too far and off center.

The F8 sample app has a ZoomableImage module (https://github.com/fbsamples/f8app/blob/b5df451259897d1838933f01ad4596784325c2ad/js/tabs/maps/ZoomableImage.js) which uses the Image.resizeMode.contain style to make an image fit the screen, but that loses the quality of image, so when you zoom in it gets blurry.


How can i remove the default launch screen in react native IOS project

$
0
0

I am creating a new project in react-native 0.61v.How to hide the default splash screen in react-native IOS.

Network connection was lost during `application:openURL:options`

$
0
0

We are using deep links to complete verification for an app we're working on. Said deep links cause the app delegate method:

- (BOOL)application:(UIApplication *)application
   openURL:(NSURL *)url
   options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{

To be called. This app is using React Native, using the in-build Linking API. Some of the time making a network request when we get the Linking callback works, but sometimes we get a networking error:

Task <D47D1F90-E2D1-4AB7-8706-8737B68CC5E8>.<180> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=53, NSUnderlyingError=0x283352ac0 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x281ed9130 [0x1e9babcb0]>{length = 16, capacity = 16, bytes = 0x100201bb34d2847e0000000000000000}, _kCFStreamErrorCodeKey=53, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <D47D1F90-E2D1-4AB7-8706-8737B68CC5E8>.<180>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <D47D1F90-E2D1-4AB7-8706-8737B68CC5E8>.<180>"

I've had a pretty extensive google and it seems to be suggested that this can be caused when a network request is made in the background, however Apple quite clearly state in the docs for this method:

If a URL arrives while your app is suspended or running in the background, the system moves your app to the foreground prior to calling this method.

Is there something we shouldn't be doing here? Has anyone else seen similar issues?

Update

It seems this works fine first time the link is opened after app-launch, but subsequent calls fail. Nothing seems to be called in a different order, so it's very confusing why we'd see this sort of pattern!

Get size of a View in React Native

$
0
0

Is it possible to get the size (width and height) of a certain view? For example, I have a view showing the progress:

<View ref='progressBar' style={{backgroundColor:'red',flex:this.state.progress}} /> 

I need to know the actual width of the view to align other views properly. Is this possible?

How to load local svg file with react-native-svg library

$
0
0

I am trying to load a local svg file in react-native with react-native-svg library, i have already installed it but i can't figure out how to do it with local svg files. the file is located in "./assets/bg.svg" and i am using expo. please write the exact code if you know.

React Native IAP Auto Renewal Subscription check Expiration

$
0
0

I am trying to restore and detect the end of auto renewal subscriptions on iOS using https://www.npmjs.com/package/react-native-iap/v/4.0.8 By calling getAvailablePurchases() I get a different number of purchases everytime I invoke this function (e.g 7, next time 23, then 4..). This makes no sense to me. I know the subscription renews any 5 minutes for monthly subscription. My idea is to get the latest purchase and just check the expired dates in the receipt from this one. (at the moment I am parsing over all of them, this cannot be best practice). Another thing is that I detect several active purchases with different transactionReceipts eventhough there is just one active.

RNIap.getAvailablePurchases().then((purchases) => {
            if(purchases != undefined && purchases.length > 0){
                alert(purchases.length + ' purchases');
                purchases.forEach((purchase) => {
                    const receiptBody = {
                        'receipt-data': purchase.transactionReceipt,
                        'password': appSubscriptionId
                    };
                    RNIap.validateReceiptIos(receiptBody, true).then((result) => { // false for production
                        let from, to, lastRenewal = '';
                        if(result.status == 0){ // 0 means receipt is correct..
                            result.latest_receipt_info.forEach((info) => { 
                                if(this.dateIsInFuture(info.expires_date)){
                                    to = moment.utc(info.expires_date, "YYYY-MM-DD HH:mm:ss").toString();
                                    from = moment.utc(info.original_purchase_date, "YYYY-MM-DD HH:mm:ss").toString();
                                    lastRenewal = moment.utc(info.purchase_date, "YYYY-MM-DD HH:mm:ss").toString();
                                    this.setState({ premium: true, from: from, to: to, lastRenewal: lastRenewal});
                                }else{
                                    alert('nicht aktiv');
                                }
                            });
                        }
                    }); 
                }); 
            }else{
                alert('No purchases found');
            }
        });

React-native app crashs after firebase/admob added because of `GADApplicationIdentifier`

$
0
0

I'm adding firebase/admob to a RN app, i've added applicationId for both Android and IOS, Android works no problem i can see test banner, but IOS crash with this error :

error screenshot

I've added GADApplicationIdentifier in info.plist:

<key>GADIsAdManagerApp</key>
    <true/>
  <key>GADApplicationIdentifier</key>
  <string>my_application_id</string>

THANKS!

How to customize icon of expo push notifications?

$
0
0

I'm sending push notifications to an expo app, and I would like to customize the icon of the notification. How can this be done?


React Native - launchPackager.command cant be opened

$
0
0

I am having trouble building react native ios project.

Error message:

"launchPackage command" can't be opened because it is from an unidentified developer.

enter image description here

Any idea how to fix this?

Firebase create Dynamic Link not working in react native iOS. However it seems to work fine in android

$
0
0

I have created a dynamic link using :

var link = new firebase.links.DynamicLink(
      "https://freshc.in",
      "frendy.page.link",
    ).android
      .setPackageName("in.frendy.app")
      .ios.setBundleId("in.freshchat.app");
    console.log('link', link); //This is giving the console in both android and ios

    firebase
      .links()
      .createDynamicLink(link)
      .then(url => {
        console.log('Dynamic Link', url); //This is not working in iOS.
        link = "http://" + decodeURIComponent(url);
      });

The above code is working fine in android but when we move on to iOS it throws an error that :

Possible Unhandled Promise Rejection (id: 0): Error: Failed to create Dynamic Link Error: Failed to create Dynamic Link at createErrorFromErrorData (blob:http://localhost:8081/e76b670d-7fe9-40cb-b837-aa0d40d85769:2122:17) at blob:http://localhost:8081/e76b670d-7fe9-40cb-b837-aa0d40d85769:2074:27 at MessageQueue.__invokeCallback (blob:http://localhost:8081/e76b670d-7fe9-40cb-b837-aa0d40d85769:2645:18) at blob:http://localhost:8081/e76b670d-7fe9-40cb-b837-aa0d40d85769:2376:18 at MessageQueue.__guard (blob:http://localhost:8081/e76b670d-7fe9-40cb-b837-aa0d40d85769:2549:13) at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/e76b670d-7fe9-40cb-b837-aa0d40d85769:2375:14) at http://localhost:8081/debugger-ui/debuggerWorker.js:80:58

Also note that I can open the application when I search from google with the app prefix name like in.freshachat.app:// But I don't get the link

What might be causing this issue?

How to handle app icon badge count when app receives notification in background(closed) on react-native using expo? (IOS)

react-native-image-picker not returning data from camera

$
0
0

I'm using react-native-image-picker to load photos. This seems to work well for photos pulled out of the camera roll, but if the user chooses to take a photo, there's no data in the response, just an empty string.

I'm using these options:

{
  title: 'Upload Photo',
  cancelButtonTitle: 'Cancel',
  takePhotoButtonTitle: 'Take Photo...',
  chooseFromLibraryButtonTitle: 'Choose from Library...',
  noData: false,
  mediaType: 'photo',
  quality: 0.2,
}

and launching the image picker with:

UIImagePickerManager.showImagePicker(options, (response) => {
  console.log(response);
});

will work fine for images picked out of the camera roll, but will give me an empty string for response.data when an new image is taken with the camera.

What gives?

React-Native iOS - How to show a view controller after Launch screen, before initialising react native bridge (iOS)

$
0
0

I have an animation that is in a native iOS view controller(swift), and I want to show that Animation View Controller for 3 seconds before launching the react-native bridge.

I tried to play around with the appdelegate.m file, here's what I came up with😩.

RN version 0.61

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"AnimationView" bundle:[NSBundle mainBundle]];
     UIViewController *vc =[storyboard instantiateInitialViewController];


  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"SplashScreenFinal"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
     self.window.rootViewController = vc;
     [self.window makeKeyAndVisible];


  if (after 3 secs) {
      self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
      UIViewController *rootViewController = [UIViewController new];
      rootViewController.view = rootView;
      self.window.rootViewController = rootViewController;
      [self.window makeKeyAndVisible];

  }
  return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

Thanks.

How to delete Firebase Cloud Messaging Token when user Log-Out of the React Native application?

$
0
0

I use React Native FCM for messaging, and when the user logs out the application I want to delete the FCM token so that the user doesn't get Notified again.

Below is my code for logout.

_signOutAsync = async () => {
    this.logoutEvent()
    API.post('customer/auth/logout', null, {
      headers: {
        Authorization:
          'Bearer ' + (await AsyncStorage.getItem(Config.ACCESS_TOKEN))
      }
    }).then((response) => {
      console.log(response)
    })
    this.clearData()
  }

Thanks.

React Native: Incoming app links not working on iOS

$
0
0

In our app, Firebase Dynamic Links stopped working some days ago without changing anything. This issue occurs on iOS only. We tested old releases of our app, and also old iOS versions, but the links don't work anywhere anymore. So we have no idea what can have changed and caused this issue.

The Xcode Console outputs the following Error when trying to open a dynamic link:

-[RNFirebaseLinks application:continueUserActivity:restorationHandler:]_block_invoke [Line 83] Failed to handle universal link: https://XXX.page.link/XXX

The app still opens, but the dispatchUrl callback is not called anymore:

Firebase.links().getInitialLink().then(this.dispatchUrl);
Firebase.links().onLink(this.dispatchUrl);

After uninstalling the app and installing it again, the link works one time initially, then stops working again.

We noticed, that Linking.getInitialURL() works (only on iOS), but Linking.addEventListener('url', ...) does not. So we still can't handle app links that are called while the app is running.

Here are some relevant files from our set-up:

package.json

{
  "name": "XXX",
  "version": "3.5.0",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "tsc": "tsc",
    "ios": "react-native run-ios --scheme Development --configuration Dev.Debug",
    "ios-beta": "react-native run-ios --scheme Beta --configuration Beta.Debug",
    "ios-prod": "react-native run-ios --scheme Production --configuration Production.Debug",
    "ios iPhone 5s": "react-native run-ios --scheme Development --configuration Dev.Debug --simulator \"iPhone 5s\"",
    "ios iPhone 6": "react-native run-ios --scheme Development --configuration Dev.Debug --simulator \"iPhone 6\"",
    "ios iPhone 8": "react-native run-ios --scheme Development --configuration Dev.Debug --simulator \"iPhone 8\"",
    "ios iPhone X": "react-native run-ios --scheme Development --configuration Dev.Debug --simulator \"iPhone X\"",
    "ios iPhone 11": "react-native run-ios --scheme Development --configuration Dev.Debug --simulator \"iPhone 11\"",
    "ios iPad (5th generation)": "react-native run-ios --scheme Development --configuration Dev.Debug --simulator \"iPad (5th generation)\"",
    "android": "react-native run-android --variant=devDebug --appId=XXX",
    "android-dev-release": "cd android && ./gradlew assembleDevRelease",
    "android-dev-install": "adb install android/app/build/outputs/apk/dev/release/app-dev-release-unsigned.apk",
    "android-beta": "react-native run-android --variant=betaDebug  --appId=XXX",
    "android-prod": "react-native run-android --variant=prodDebug",
    "postinstall": "./node_modules/react-native-maps/enable-google-maps ./ios && rndebugger-open && react-native-schemes-manager all",
    "postversion": "react-native-version --skip-tag --never-amend",
    "git-local-prune": "git branch -vv | grep ': \\(gone\\|entfernt\\)]'|  grep -v '\\*' | awk '{ print $1; }' | xargs git branch -d",
    "xcode": "open ios/XXX.xcworkspace"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.1",
    "@turf/distance": "^6.0.1",
    "decko": "1.2.0",
    "firebase": "^5.5.9",
    "geofirestore": "^3.3.1",
    "jsc-android": "224109.x.x",
    "lottie-ios": "^2.5.0",
    "lottie-react-native": "^2.5.10",
    "mobx": "^5.15.4",
    "mobx-react": "^5.3.3",
    "moment": "^2.23.0",
    "react": "^16.8.6",
    "react-native": "^0.59.10",
    "react-native-actionsheet": "^2.4.2",
    "react-native-android-location-services-dialog-box": "^2.8.0",
    "react-native-contacts": "^4.0.3",
    "react-native-device-info": "^0.25.1",
    "react-native-fabric": "0.5.2",
    "react-native-fast-image": "~5.2.0",
    "react-native-fbsdk": "^0.10.0",
    "react-native-firebase": "5.2.1",
    "react-native-google-signin": "^1.2.1",
    "react-native-i18n": "^2.0.15",
    "react-native-image-picker": "~0.28.0",
    "react-native-image-progress": "~1.1.1",
    "react-native-image-resizer": "~1.0.1",
    "react-native-image-zoom-viewer": "2.2.24",
    "react-native-maps": "0.23.0",
    "react-native-permissions": "^1.1.1",
    "react-native-progress": "~3.5.0",
    "react-native-snackbar": "^1.0.2",
    "react-native-snap-carousel": "~3.7.5",
    "react-native-status-bar-height": "^2.2.0",
    "react-native-svg": "^8.0.11",
    "react-native-webview": "^5.12.1",
    "react-native-youtube": "^1.1.0",
    "react-navigation": "^2.18.0",
    "rn-fetch-blob": "0.10.15",
    "rn-placeholder": "~1.3.2",
    "rn-viewpager": "~1.2.9",
    "semver": "~5.6.0",
    "styled-components": "3.4.9",
    "ts-optchain": "~0.1.2",
    "url-parse": "^1.4.4"
  },
  "devDependencies": {
    "@babel/plugin-proposal-decorators": "^7.1.2",
    "@babel/runtime": "^7.1.2",
    "@types/jest": "^23.3.5",
    "@types/lodash": "~4.14.120",
    "@types/react": "^16.8.19",
    "@types/react-native": "~0.57.60",
    "@types/react-native-fbsdk": "^0.7.0",
    "@types/react-native-i18n": "~2.0.0",
    "@types/react-native-permissions": "^1.1.1",
    "@types/react-native-snap-carousel": "~3.7.1",
    "@types/react-native-status-bar-height": "^2.1.0",
    "@types/react-navigation": "^2.0.24",
    "@types/react-test-renderer": "^16.0.3",
    "@types/semver": "~5.5.0",
    "@types/url-parse": "^1.4.2",
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "marked": "^0.7.0",
    "metro": "^0.54.0",
    "metro-react-native-babel-preset": "^0.54.0",
    "prettier": "^1.14.3",
    "react-native-debugger-open": "~0.3.17",
    "react-native-schemes-manager": "^1.0.5",
    "react-native-version": "^2.6.7",
    "react-test-renderer": "16.6.3",
    "tslint": "^5.11.0",
    "typescript": "^3.7.5"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "./src/assets/fonts/"
    ]
  },
  "prettier": {
    "printWidth": 140,
    "tabWidth": 4,
    "useTabs": false,
    "singleQuote": true,
    "trailingComma": "none",
    "bracketSpacing": true,
    "parser": "typescript"
  },
  "xcodeSchemes": {
    "Debug": [
      "Beta.Debug",
      "Dev.Debug"
    ],
    "Release": [
      "Beta.Release",
      "Dev.Release"
    ],
    "projectDirectory": "ios"
  }
}

ios/Podfile

target 'XXX' do
    rn_path = '../node_modules/react-native'
    rn_maps_path = '../node_modules/react-native-maps'

    platform :ios, '9.0'

    # Pods for XXX
    pod 'React', :path => rn_path, :subspecs => [
        'Core',
        'CxxBridge',
        'DevSupport',
        'RCTActionSheet',
        'RCTAnimation',
        'RCTGeolocation',
        'RCTImage',
        'RCTLinkingIOS',
        'RCTNetwork',
        'RCTSettings',
        'RCTText',
        'RCTVibration',
        'RCTWebSocket',
    ]
    pod 'yoga', :path => "#{rn_path}/ReactCommon/yoga"
    pod 'RNI18n', :path => '../node_modules/react-native-i18n'

    pod 'lottie-ios', :path => '../node_modules/lottie-ios'

    pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'

    pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image'

    pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
    pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'

    # Required by RNFirebase
    pod 'Firebase/Core', '~> 5.14.0'
    pod 'Firebase/Auth', '~> 5.14.0'
    pod 'Firebase/DynamicLinks', '~> 5.14.0'
    pod 'Firebase/Firestore', '~> 5.14.0'
    pod 'Firebase/Messaging', '~> 5.14.0'
    pod 'Firebase/Database', '~> 5.14.0'
    pod 'Firebase/RemoteConfig', '~> 5.14.0'

    # Google Tag Manager
    pod 'GoogleTagManager', '~> 7.0'

    # Crashlytics
    pod 'Fabric', '~> 1.7.13'
    pod 'Crashlytics', '~> 3.10.7'

    pod 'ReactNativeFabric', :path => '../node_modules/react-native-fabric'

    # React Native third party dependencies podspecs
    pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
    #pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
    pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

    # react-native-maps dependencies
    pod 'react-native-maps', path: rn_maps_path
    pod 'react-native-google-maps', path: rn_maps_path  # Unomment this line if you want to support GoogleMaps on iOS
    pod 'GoogleMaps'  # Uncomment this line if you want to support GoogleMaps on iOS
    pod 'Google-Maps-iOS-Utils' # Uncomment this line if you want to support GoogleMaps on iOS

    # Youtube dependencies
    pod 'react-native-youtube', :path => '../node_modules/react-native-youtube'
    pod 'XCDYouTubeKit', '~> 2.5'

    pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
    pod 'RNGoogleSignin', :path => '../node_modules/react-native-google-signin'
    pod 'GoogleSignIn', '~> 4.4.0'

    pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk'
    # https://github.com/facebook/react-native-fbsdk/issues/509
    pod 'FBSDKCoreKit', '~> 5.0.0'
    pod 'FBSDKLoginKit', '~> 5.0.0'
    pod 'FBSDKShareKit', '~> 5.0.0'

    pod 'RNSnackbar', :path => '../node_modules/react-native-snackbar'
    pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'
    pod 'react-native-image-resizer', :path => '../node_modules/react-native-image-resizer'

    pod 'react-native-webview', :path => '../node_modules/react-native-webview'

    pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

    target 'XXXTests' do
        inherit! :search_paths
        # Pods for testing
    end

end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'react-native-google-maps'
            target.build_configurations.each do |config|
                config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
            end
        end
        if target.name == "React"
            target.remove_from_project
        end
    end
    system('node ./generatePodsHtml.js')
end

AppDelegate.m

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"
#import "RNFirebaseLinks.h"
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>

#import <React/RCTRootView.h>

#import <Firebase.h>

#import <GoogleMaps/GoogleMaps.h>

#import <RNGoogleSignin/RNGoogleSignin.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   NSString *path = [[NSBundle mainBundle] pathForResource: @"Info" ofType: @"plist"];
   NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: path];
   NSString *apiKey = [dict objectForKey: @"GOOGLE_API_KEY"];
  [GMSServices provideAPIKey:apiKey];

  [FIROptions defaultOptions].deepLinkURLScheme = @"XXX";
  [FIRApp configure];
//  [FIRDatabase database].persistenceEnabled = YES;
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  [RNFirebaseNotifications configure];

  NSURL *jsCodeLocation;
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"XXX"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<NSString *, id> *)options {
  BOOL handled = [[RNFirebaseLinks instance] application:application openURL:url options:options];

  if (!handled) {
    handled = [RNGoogleSignin application:application
                                  openURL:url
                        sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                               annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
  }

  if (!handled) {
    handled = [[FBSDKApplicationDelegate sharedInstance] application:application
                                                             openURL:url
                                                   sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                          annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
  }

  if (!handled) {
    handled = [RCTLinkingManager application:application openURL:url options:options];
  }

  return handled;
}

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  return [[RNFirebaseLinks instance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  [[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
  [[RNFirebaseMessaging instance] didReceiveRemoteNotification:response.notification.request.content.userInfo];
  completionHandler();
}

@end

Verifying/signing that a request to my API came from my app and was not spoofed (React Native)

$
0
0

Is it possible to verify that an API call to my server came from my app and was not spoofed with another HTTP request client or similar? I'm using React Native with Node on the back-end, and am using a JWT system for authentication.

Context: certain features are only unlocked for users that the app has detected are at a certain location. The only system I can think of for unlocking these is pretty weak - the front-end sends a request to the server with the user's location, and if the location fits then the features are unlocked. Obviously this request can be spoofed easily, unless I can sign them in a certain way that is unique to the app and is difficult to reverse-engineer.

Any other approaches would be appreciated (e.g. detect the user's location from the IP address that the request was sent from?)

Building React Native for iOS fails: code signature not vaild for AppAuth

$
0
0

I am trying to integrate react-native-app-auth into my React Native app. It works on Android, but when trying to build the project on iOS I get the following:

dyld: Library not loaded: @rpath/AppAuth.framework/AppAuth
  Referenced from: /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/MapMobileWorkbench
  Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=25
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=1
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=1
(lldb) 

After that pops up, continuing the run the app causes it to crash.

React Native Info:

  React Native Environment Info:
    System:
      OS: macOS 10.14.6
      CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 1.29 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.16.1 - /var/folders/2p/5xwrclh55wjc5glqmnwdcbqm0000gp/T/yarn--1582121305976-0.1309360786018443/node
      Yarn: 1.22.0 - /var/folders/2p/5xwrclh55wjc5glqmnwdcbqm0000gp/T/yarn--1582121305976-0.1309360786018443/yarn
      npm: 6.9.0 - ~/.nvm/versions/node/v10.16.1/bin/npm
    SDKs:
      iOS SDK:
        Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    IDEs:
      Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.5 => 0.59.5 

Both the .a library and the .framework for AppAuth are in the link list for the target I am building, but the color of the icon for the .framework file is more of a pale yellow versus the regular yellow of the rest of the .framework files linked. That is the only thing I have noticed that might mean something. I have tried deleting and reinstalling my pods a number of times without any luck there, either. And I have tried both the new and the legacy build systems. I am not sure what else to try.

react-native: command not found

$
0
0

I am getting -bash: react-native: command not found error while creating react-native project.

Below are the additional info

1. brew --version
   homebrew 0.9.9
2  brew info watchman
   watchman `enter code here`stable 4.50
   /usr/local/Cellar/watchman/4.4.0
3. brew info flow
   stable 0.24.1
   /usr/local/Cellar/flow/0.24.1
4. brew info node
   stable 6.1.0
   /usr/local/Cellar/node/6.1.0
5. npm -version
   3.8.6
6. echo $PATH
/Users/Ashok/.rbenv/shims:/Users/Ashok/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I tried suggested steps from the below link but still i am getting same error.

  1. react-native-command-not-found

I don't have any "npm" directory which they have specified in the solution

Ashoks-MacBook-Pro:share Ashok$ ls
aclocal     doc     info        ruby-build  zsh
autoconf    emacs       man     systemtap

But i found npm file exist in below location.

/usr/local/Cellar/node/6.1.0/etc/bash_completion.d

I uninstalled react-native and installed again but still i am facing same issue.

How to make React Native Animated.View clickable?

$
0
0

I'm using this react native tinder demo ->https://github.com/brentvatne/react-native-animated-demo-tinder

Is it possible to make the cards 'clickable' so it would navigate to another view on click? I've tried wrapping the "Touchable" components around the animated view but doing so disables the animations.

Any ideas would be highly appreciated, thanks!

get InvalidRegistration when send notifications with POST MAN using firebase in react native IOS app [duplicate]

$
0
0

I'm trying to send notification with post man to my react native IOS app .

In post man i send POST request :

Headers : 
Content-Type: application/json
Authorization: key=XXXXXXX ( i put firebase cloud messaging server key)

Body:
  // to   i put the device token

{
"to": "xxxx",
"data": {
    "message" : "lorem"
}

}

in my AppDelegate.m

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
// [START set_messaging_delegate]
  [FIRMessaging messaging].delegate = self;
  // [END set_messaging_delegate]

  // Register for remote notifications. This shows a permission dialog on first run, to

  // [START register_for_notifications]
  if ([UNUserNotificationCenter class] != nil) {

          // ...
        }];
  } else {
     // ..
  }

  [application registerForRemoteNotifications];
  // [END register_for_notifications]

  return YES;
}

and then i added other functions like the documentations of firebase IOS :

   // [START refresh_token]
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {

}
// [END refresh_token]



// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
  [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

//
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
  ... 
}
// [END receive_message]

Actually i receive this response :

{
    "multicast_id": 1804810573619574964,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidRegistration"
        }
    ]
}

and i don't get any notification in my device

Viewing all 17221 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>