Skip to content

Commit

Permalink
fix: instagram-stories build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
hbarylskyi committed Oct 2, 2019
1 parent 6bacbcd commit 56f50cc
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 40 deletions.
48 changes: 27 additions & 21 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@
* @flow
*/

import React, {useState} from 'react';

import {
Alert,
Button,
Platform,
TextInput,
StyleSheet,
Text,
View,
} from 'react-native';
import React, { useState } from 'react';

import { Alert, Button, Platform, TextInput, StyleSheet, Text, View } from 'react-native';

// eslint-disable-next-line import/default
import Share from 'react-native-share';
Expand All @@ -35,12 +27,9 @@ const App = () => {
* Only works on Android.
*/
const checkIfPackageIsInstalled = async () => {
const {isInstalled} = await Share.isPackageInstalled(packageSearch);
const { isInstalled } = await Share.isPackageInstalled(packageSearch);

Alert.alert(
`Package: ${packageSearch}`,
`${isInstalled ? 'Installed' : 'Not Installed'}`,
);
Alert.alert(`Package: ${packageSearch}`, `${isInstalled ? 'Installed' : 'Not Installed'}`);
};

function getErrorString(error, defaultValue) {
Expand Down Expand Up @@ -119,6 +108,23 @@ const App = () => {
}
};

const shareToInstagramStory = async () => {
const shareOptions = {
title: 'Share image to instastory',
method: Share.InstagramStories.SHARE_BACKGROUND_IMAGE,
backgroundImage: images.image1,
social: Share.Social.INSTAGRAM_STORIES,
};

try {
const ShareResponse = await Share.shareSingle(shareOptions);
setResult(JSON.stringify(ShareResponse, null, 2));
} catch (error) {
console.log('Error =>', error);
setResult('error: '.concat(getErrorString(error)));
}
};

return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native Share Example!</Text>
Expand All @@ -132,6 +138,9 @@ const App = () => {
<View style={styles.button}>
<Button onPress={shareEmailImage} title="Share Social: Email" />
</View>
<View style={styles.button}>
<Button onPress={shareToInstagramStory} title="Share to IG Story" />
</View>
{Platform.OS === 'android' && (
<View style={styles.searchPackageContainer}>
<TextInput
Expand All @@ -141,14 +150,11 @@ const App = () => {
style={styles.textInput}
/>
<View>
<Button
onPress={checkIfPackageIsInstalled}
title="Check Package"
/>
<Button onPress={checkIfPackageIsInstalled} title="Check Package" />
</View>
</View>
)}
<Text style={{marginTop: 20, fontSize: 20}}>Result</Text>
<Text style={{ marginTop: 20, fontSize: 20 }}>Result</Text>
<Text style={styles.result}>{result}</Text>
</View>
</View>
Expand Down
21 changes: 21 additions & 0 deletions example/ios/example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,15 @@
TargetAttributes = {
00E356ED1AD99517003FC87E = {
CreatedOnToolsVersion = 6.2;
ProvisioningStyle = Manual;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
ProvisioningStyle = Manual;
};
2D02E47A1E0B4A5D006451C7 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = DCCMUU4M4M;
ProvisioningStyle = Automatic;
};
2D02E48F1E0B4A5D006451C7 = {
Expand Down Expand Up @@ -562,6 +564,8 @@
baseConfigurationReference = 4F16D0649B2B77A7EF0670D9 /* Pods-exampleTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
Expand All @@ -583,6 +587,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example";
};
name = Debug;
Expand All @@ -592,7 +598,9 @@
baseConfigurationReference = 233D73EB20913C5DCE90EC0F /* Pods-exampleTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
DEVELOPMENT_TEAM = "";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../../ios/**",
Expand All @@ -610,6 +618,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example";
};
name = Release;
Expand All @@ -619,6 +629,7 @@
baseConfigurationReference = 5462B1C7438CB375E7D9E441 /* Pods-example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
Expand All @@ -628,6 +639,7 @@
"$(SRCROOT)/../../ios/**",
);
INFOPLIST_FILE = example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
Expand All @@ -637,6 +649,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = example;
PROVISIONING_PROFILE_SPECIFIER = "";
VALID_ARCHS = "arm64 arm64e armv7 armv7s";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand All @@ -646,14 +659,17 @@
baseConfigurationReference = BC4A9C18F3C43AE93D3FAEF7 /* Pods-example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = "";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../../ios/**",
);
INFOPLIST_FILE = example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
Expand All @@ -663,6 +679,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = example;
PROVISIONING_PROFILE_SPECIFIER = "";
VALID_ARCHS = "arm64 arm64e armv7 armv7s";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
Expand All @@ -677,7 +694,9 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
DEAD_CODE_STRIPPING = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = DCCMUU4M4M;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
HEADER_SEARCH_PATHS = (
Expand Down Expand Up @@ -713,7 +732,9 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = DCCMUU4M4M;
GCC_NO_COMMON_BLOCKS = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "example.app"
BlueprintName = "example"
ReferencedContainer = "container:example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -67,22 +76,11 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "example.app"
BlueprintName = "example"
ReferencedContainer = "container:example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
buildConfiguration = "Release"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -99,8 +97,6 @@
ReferencedContainer = "container:example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
4 changes: 4 additions & 0 deletions example/ios/example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo library access for testing sharing functionalities</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down Expand Up @@ -40,6 +42,8 @@
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram-stories</string>
<string>instagram</string>
<string>facebook</string>
<string>whatsapp</string>
<string>mailto</string>
Expand Down
5 changes: 3 additions & 2 deletions ios/InstagramShare.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ - (void)shareSingle:(NSDictionary *)options
successCallback(@[]);
} else {
// Cannot open instagram
NSString *stringURL = @"http://itunes.apple.com/app/instagram/id389801252";
NSString *stringURL = @"https://itunes.apple.com/app/instagram/id389801252";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {}];

NSString *errorMessage = @"Not installed";
NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedString(errorMessage, nil)};
Expand Down
4 changes: 4 additions & 0 deletions ios/RNShare.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,12 @@
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RNShare;
SKIP_INSTALL = YES;
VALID_ARCHS = "arm64 arm64e armv7 armv7s x86_64";
};
name = Debug;
};
Expand All @@ -263,10 +265,12 @@
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RNShare;
SKIP_INSTALL = YES;
VALID_ARCHS = "arm64 arm64e armv7 armv7s x86_64";
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"pre-commit": "lint:staged",
"readmeFilename": "README.md",
"scripts": {
"dev-sync": "cp -r *podspec android ios example/node_modules/react-native-share/",
"dev-sync": "cp -r *podspec *.js android ios example/node_modules/react-native-share/",
"lint": "eslint index.js --max-warnings=0",
"lint:staged": "lint-staged",
"release:major": "node ./changelog --major && npm version major && git push origin && git push origin --follow-tags",
Expand Down

0 comments on commit 56f50cc

Please sign in to comment.