尝试将Facebook OAuth与SafariViewController一起使用.首先,我使用SafariViewController打开authURL,如果用户在Safari上登录到Facebook,将重定向它们并返回带有该特定服务的令牌的OAuth URL,例如Instagram
回应:https://www.facebook.com/connect/login_success.html#access_token=BLAHTOKENRESPONSE&expires_in=5114338
当SafariViewController重定向时,我想获取响应URL并存储它,以便我可以获取令牌.这是我的代码:
import SafariServices
let kSafariViewControllerCloseNotification = "kSafariViewControllerCloseNotification"
import UIKit
// facebook OAuth URL for service
let authURL = NSURL(string: "https://www.facebook.com/dialog/oauth?client_id=3627644767&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=basic_info,email,public_profile,user_about_me,user_activities,user_birthday,user_education_history,user_friends,user_interests,user_likes,user_location,user_photos,user_relationship_details&response_type=token")
class ViewController: UIViewController, SFSafariViewControllerDelegate {
var safariVC: SFSafariViewController?
@IBOutlet weak var loginButton: UIButton!
@IBAction func loginButtonTapped(sender: UIButton) {
safariVC = SFSafariViewController(URL: authURL!)
safariVC!.delegate = self
self.presentViewController(safariVC!, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// not firing the safariLogin function below
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.safariLogin(_:)), name: kSafariViewControllerCloseNotification, object: nil)
}
func safariLogin(notification: …
Run Code Online (Sandbox Code Playgroud) 是否可以将一个大纲或textShadow添加到反应原生的字体中以实现类似这样的字体(带有黑色轮廓的白色字体):
在Web上的CSS中,可以为字体添加文本阴影或轮廓,为文本提供字体后面的边框,如下所示:
h1 {
color: yellow;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
Run Code Online (Sandbox Code Playgroud)
<h1>Hello World</h1>
Run Code Online (Sandbox Code Playgroud)
在本地做出反应是否有可能做类似的事情?
我从这个堆栈溢出帖子中获取了关于如何使用CSS:CSS字体边框的CCS片段示例?
编辑:更新了问题,试图让它更清晰
是否可以强制ListView重新渲染,即使dataSource中的数据没有更改?我在我的应用程序的选项卡栏中有一个ListView,我希望每次选择该选项卡时都重绘它,无论数据是相同还是已更改.
this.state = {
data: props.data,
dataSource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
}
componentWillMount() {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(nextProps.data)
})
}
render() {
<ListView
dataSource={this.state.data}
renderRow={this._renderRow}
/>
}
Run Code Online (Sandbox Code Playgroud)
我试着玩这些rowHasChanged
争论,但这没有帮助.任何帮助将非常感激
使用FCM,当应用程序处于后台或未运行时,我会在系统托盘中收到推送通知.当应用程序在前台时,我可以覆盖onMessageReceived并创建我自己的抬头通知NotificationCompat
.
当我的应用程序在后台运行或未运行时,有没有办法创建提醒通知?
谢谢
编辑:这里的参考是我通过curl使用的消息有效负载https://fcm.googleapis.com/fcm/send
{
"to":"push-token",
"content_available": true,
"priority": "high",
"notification": {
"title": "Test",
"body": "Mary sent you a message!",
"sound": "default"
},
"data": {
"message": "Mary sent you a Message!",
"notificationKey":"userID/notification_type",
"priority": "high",
"sound": "default"
}
}
Run Code Online (Sandbox Code Playgroud) android android-notifications heads-up-notifications firebase-cloud-messaging
我有一个APNS证书,将于2017年1月在实际应用程序上过期.我续签证书,并创建了.cer
和.p12
文件.
我正在使用Firebase Cloud Messaging来处理推送通知.如果我现在将新.p12
文件添加到firebase控制台,是否会覆盖当前的文件并在实时应用程序上中断推送通知?
如果是这样,我如何管理到新证书的无缝过渡?我是否只是等到新应用程序在应用程序商店中存在然后上传.p12
?
谢谢,
apple-push-notifications ios firebase firebase-cloud-messaging
我试图围绕openface api编写一个小瓶子REST API包装器,这样我就可以将POST
URL映像到我的烧瓶服务器并让它运行图像与分类器模型的比较
app = Flask(__name__)
@app.route('/compare', methods=['POST'])
def compare():
# create arguments object with default classifier and neural net
args = CompareArguments(image)
image = request.json['image']
args.imgs = image
align = openface.AlignDlib(args.dlibFacePredictor)
net = openface.TorchNeuralNet(args.networkModel, imgDim=args.imgDim, cuda=args.cuda)
# call openface and compare image to classifier
infer(args, align, net)
return jsonify({'image': image}), 201
if __name__ == '__main__':
app.run(host='0.0.0.0', threaded=True)
Run Code Online (Sandbox Code Playgroud)
如果我发布这样的图像
curl -i -H "Content-Type: application/json" -X POST http://localhost:5000/compare -d '{"image": [ "../images/examples/clapton-1.jpg"]}'
Run Code Online (Sandbox Code Playgroud)
创建了一个新的火炬进程,可以在输出中看到ps -aux
,但似乎被阻止,因为它在服务器重新加载之前不会运行
USER …
Run Code Online (Sandbox Code Playgroud) 在React Native AppState库中:
iOS有三种状态background-> inactive-> active
Android只有background-> active
当Android应用完全落后时,MainActivity来自onPause - > onStop
当有系统通知时,例如In app购买,它会进入onPause
当应用程序从后台转到前台onStop - > onResume时,我需要运行一些代码
如果由于系统通知onPause - > onResume而短暂暂停应用程序,我不希望它运行
这可能吗?React的生命周期事件没有onHostStop
我尝试从MainActivity为每个Activity生命周期事件发出一个事件,但这导致App崩溃并出现空指针异常.
甚至可以从MainActivity向React Native发出事件吗?
谢谢
编辑添加了代码以显示从MainActivity发出事件的尝试
MainActivity.java片段
import com.facebook.react.ReactActivity;
import com.facebook.react.modules.core.DeviceEventManagerModule;
public class MainActivity extends ReactActivity {
DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter;
@Override
public void onStop() {
super.onStop();
eventEmitter.emit("onStop", "ActivityonStop");
}
}
Run Code Online (Sandbox Code Playgroud)
反应原生
const nativeEventListener = DeviceEventEmitter.addListener('onStop',
(e)=>{
console.log("NATIVE_EVENT");
dispatch({type: "NATIVE_EVENT"})
})
Run Code Online (Sandbox Code Playgroud)
logcat中的错误
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.realer.android, PID: 15251
java.lang.RuntimeException: …
Run Code Online (Sandbox Code Playgroud) 我想我使用Xcode正确创建了源地图。需要这个用于生产构建。
我补充说:
react-native bundle --platform ios --entry-file index.ios.js --dev false --bundle-output ./ios/main.jsbundle --assets-dest ./ios --sourcemap-output ./sourcemap/sourcemap.js
Run Code Online (Sandbox Code Playgroud)
到Xcode中的Bundle React Native code and images
in build phases
,以生成似乎有效的sourcemap。
但是,当尝试使用以下代码来分析带有行号和列号的源映射时,我没有得到正确的结果
var sourceMap = require('source-map');
var fs = require('fs');
// read source-map, should be new for every build
fs.readFile('../my-app/src/sourcemap/sourcemap.js', 'utf8', function (err, data) {
var smc = new sourceMap.SourceMapConsumer(data);
// replace line and colum numbers with line/col from error output
console.log(smc.originalPositionFor({
line: 105132,
column: 98
}));
});
Run Code Online (Sandbox Code Playgroud)
我正在使用Xcode的堆栈跟踪作为测试,但我得到了null。Xcode部分输出:
2016-04-26 17:50:00.631 [error][tid:com.facebook.React.JavaScript] Can't find …
Run Code Online (Sandbox Code Playgroud) 如何获取用户 iOS 设备上完成的购买的应用内购买收据?购买后,我们需要在购买后立即验证收据(最好是在SKPaymentTransactionObserver
)。否则,当我们尝试单独验证本地收据时......它已经过时了!
下面是我的交易观察者:
extension StoreManager: SKPaymentTransactionObserver {
func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print("Received Payment Transaction Response from Apple");
for transaction:AnyObject in transactions {
// check object is a transaction first
if let trans:SKPaymentTransaction = transaction as? SKPaymentTransaction{
switch trans.transactionState {
case .Purchased:
print("Product Purchased");
SKPaymentQueue.defaultQueue().finishTransaction(transaction as! SKPaymentTransaction)
// invoke any callback waiting to be called
purchaseCallbackHolder?([trans.pseudoReceipt]) // here is where I'd like to extract the receipt associated with the transaction
purchaseCallbackHolder = nil
break;
case …
Run Code Online (Sandbox Code Playgroud) 如果取消提交尚未解决一段时间后,我想向用户显示超时错误.
我已经看到了一些在这里添加setTimeout来获取的好例子:https: //github.com/github/fetch/issues/175
但是,如何处理同时使用redux的获取承诺?例如
export function getData() {
return (dispatch, getState) => {
fetch('blah.com/data')
.then(response => response.json())
.then(json => dispatch(getDataSuccess(json)))
.catch(
error => {
console.log(error)
}
)
dispatch({
type: DATA_FETCH_REQUEST
})
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢阅读!
是否可以在React Native中使用defaultProps?我尝试了以下两种定义defaultProps的方法,在尝试访问defaultProp时我得到null
export default class Foo extends Component {
// 1. define defaultProps within Class
static defaultProps = {
someData: 'Hello',
}
constructor(props) {
super(props);
}
componentDidMount() {
console.log(this.props.someData);
}
render() {
return (
<View> {this.props.someData} </View>
)
}
}
// 2. define defaultProps outside Class
Foo.defaultProps = { someData: 'Hello' }
Run Code Online (Sandbox Code Playgroud)