如何定位所以推送通知发送给每个人而不是频道?
var my_msg = "Hello World";
$.ajax({
type: 'POST',
headers: {'X-Parse-Application-Id':"*****",'X-Parse-REST-API-Key':"*****"},
url: "https://api.parse.com/1/push",
data: JSON.stringify({
"channel": "",
"type":"ios",
"expiration_interval": 86400,
"data":{
"alert": my_msg,
"badge" :0,
"sound":""
}
}),
contentType: "application/json"
});
Run Code Online (Sandbox Code Playgroud) 我正在将我的iOS应用程序与Parse和Facebook集成.它在我的iPhone 4s上工作正常 - 运行iOS 6 - 但是当我在我的xCode 5模拟器上尝试测试帐户时它失败了.
当我用facebook按钮登录时,我会看到一个屏幕说:你已经授权Test999(我的应用程序名称.)当我打电话给这一行时,就会发生这种情况:
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error)
Run Code Online (Sandbox Code Playgroud)
我按OK.它将我发送到"您必须先登录"屏幕.我输入了我的用户名和密码,然后按下登录状态 - 我将被发送回您已经授权的Test999.我按OK - 我看到一个空白视图,左上方有一个x来关闭它.没有别的事可做,所以我推它,我被送回"你必须先登录"屏幕.
因此,无法使用模拟器登录.我试图"重置内容和设置",但它没有帮助.
关于类似问题的答案后,我尝试添加一个reconnectWithFb方法(下面),我还将我的Facebook sdk更新到版本3.9.什么都没有帮助.
这是我用facebook方法登录的:
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
if (!user) {
if (!error) {
NSLog(@"Uh oh. The user cancelled the Facebook login.");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"User cancelled facebook login" message:@"Uh oh. The user cancelled the Facebook login." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
[alert show];
} else {
NSLog(@"welcome screen loginWithFB: Uh oh. An error occurred: %@", …Run Code Online (Sandbox Code Playgroud) 使用以下代码行:
PayPalPayment *payment = [[PayPalPayment alloc] init];
NSLog(@"Price %@",[self.product objectForKey:@"Price"]);
NSString *string = [self.product objectForKey:@"Price"];
payment.amount = [[NSDecimalNumber alloc] initWithString:string];
Run Code Online (Sandbox Code Playgroud)
我的应用程序崩溃了这个日志:
[NSDecimalNumber length]: unrecognized selector sent to instance
Run Code Online (Sandbox Code Playgroud)
NSLog正在返回:
Price 96.67
Run Code Online (Sandbox Code Playgroud)
真是崩溃???
我正在使用Parse.com服务发送推送通知并让广播接收器接收消息.我想在广播接收器中调用我的活动中的方法来显示Toast消息(实际上我想更新listview内容但是现在我只是使用Toast来检查方法是否被成功调用)而不调用活动.
首先,我遵循以下指示:
但它会产生错误:
12-20 20:53:33.892: E/AndroidRuntime(14245): FATAL EXCEPTION: main
12-20 20:53:33.892: E/AndroidRuntime(14245): java.lang.RuntimeException: Unable to start receiver event.planner.services.CustomReceiver: java.lang.NullPointerException
12-20 20:53:33.892: E/AndroidRuntime(14245): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2236)
12-20 20:53:33.892: E/AndroidRuntime(14245): at android.app.ActivityThread.access$1500(ActivityThread.java:130)
12-20 20:53:33.892: E/AndroidRuntime(14245): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
12-20 20:53:33.892: E/AndroidRuntime(14245): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 20:53:33.892: E/AndroidRuntime(14245): at android.os.Looper.loop(Looper.java:137)
12-20 20:53:33.892: E/AndroidRuntime(14245): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-20 20:53:33.892: E/AndroidRuntime(14245): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 20:53:33.892: E/AndroidRuntime(14245): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 20:53:33.892: E/AndroidRuntime(14245): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-20 20:53:33.892: E/AndroidRuntime(14245): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-20 20:53:33.892: E/AndroidRuntime(14245): at dalvik.system.NativeStart.main(Native Method)
12-20 20:53:33.892: …Run Code Online (Sandbox Code Playgroud) 我的活动中有3个编辑文本(姓名,手机号码,职业)和一个按钮(保存).我想在用户点击按钮时每次将这三个数据保存到Parse-cloud.然后使用imageview中的图像显示新活动,该活动应与相应的手机号码一起保存.
我试图通过以下代码同步从类中获取和对象:
var userName = ParseObject.GetQuery ("Users")
.WhereEqualTo("UserName","usernameOfUser") ;
var responseUserName = userName.FindAsync();
do {
} while(!responseUserName.IsCompleted || !responseUserName.IsFaulted);
if(responseUserName.IsFaulted){
Console.WriteLine("Faulted");
}
IEnumerable<ParseObject> result = responseUserName.Result;
Run Code Online (Sandbox Code Playgroud)
但'responseUserName'状态始终为"waitingForActivation".
如果我做错了,请告诉同步获取对象的正确方法.
更新:我不能使用等待.因为等待我必须将方法声明为异步.但我不希望将控制权交还给前端开发人员(UI开发人员),直到我得到查询结果.
更新2:我可以使用ContinueWith方法获得结果.但是在我得到结果之前它不会阻止执行.
var userName = ParseObject.GetQuery (Constants.TABLE_USER)
.WhereEqualTo(Constants.COL_USER_NAME,user.GetUserName());
Users RegisteredUser = new Users ();
var responseUserName = userName.FindAsync().ContinueWith(t=>{
IEnumerable<ParseObject> result = t.Result;
if (result.Count() >= 0) {
Console.WriteLine("Got Records" + result.Count());
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢
基于使用高级定位推送通知的解析指南,我理解为了PFInstallations与当前用户关联,应该通过以下方式:
PFInstallation *installation = [PFInstallation currentInstallation];
installation[@"user"] = [PFUser currentUser];
[installation saveInBackground];
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何能够"在运行中"为其他用户(即不是当前用户)做到这一点.例如,我有一个Message对象,我想发送给用户Sally,Alex和Ben:如何能够根据用户objectIds获得这些用户的PFInstallations,然后设置他们的PFInstallation,以便
//Sally, Alex and Ben's PFInstallations:
[installation setObject:YES forKey:message.objectId];
Run Code Online (Sandbox Code Playgroud)
...所以当我发出消息时,只有Sally,Alex和Ben会收到推送通知他们收到了我的消息?
谢谢!
我有一个变量int,我想将其保存为PFObject.每当我尝试时,我都会收到错误:
incompatible integer to point value from int to id.
Run Code Online (Sandbox Code Playgroud)
我可以通过执行添加一个不在变量中的普通int.
PFObject* object = [PFObject objectwithclassname:@"test"];
object[@"score"] = @30;
Run Code Online (Sandbox Code Playgroud)
这工作正常,我也可以添加一个字符串,它将工作.当我尝试这个时它不起作用.
int test = 10;
object[@"score"] = test;
Run Code Online (Sandbox Code Playgroud)
谁知道?
我有一个方法需要等待另一个方法来完成从数据存储区加载一些对象.所以我正在使用这样的while循环:
-(void) findAGoodCar {
[self.indicator startAnimating];
while(appDelegate.availableCars == nil || [appDelegate.availableCars count] < 1) {
sleep(0.01);
}
// do some stuff
}
Run Code Online (Sandbox Code Playgroud)
虽然这开始工作,但是为了装载汽车,其他过程已经开始了.
现在,该指标从未开始制作动画.对象的加载永远不会完成.循环永远不会结束.为什么?
编辑:这是我的loadCars方法.当应用程序启动时,它会从(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptionsappDelegate调用,并以异步方式向Parse.com的云进行查询:
+(void) loadCars {
PFQuery *query = [PFQuery queryWithClassName:kCarObjectKey];
[query whereKey:kActiveKey equalTo:[NSNumber numberWithInteger:kActiveNumber]];
NSSortDescriptor *sortByPrice = [[NSSortDescriptor alloc] initWithKey:kPriceKey ascending:YES];
[query orderBySortDescriptors:[NSArray arrayWithObjects:sortByPrice, nil]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if(!error) {
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
appDelegate.availableCars = objects;
} else {
NSLog(@"Error in loadCars %@", error.localizedDescription);
}
}]; …Run Code Online (Sandbox Code Playgroud) 我已经配置了我的Parse接收api,如下所示:
[Parse setApplicationId:@"***" clientKey:@"***"];
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
UIRemoteNotificationTypeAlert|
UIRemoteNotificationTypeSound];
Run Code Online (Sandbox Code Playgroud)
和
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
Run Code Online (Sandbox Code Playgroud)
然后在我的代码中,我添加了要订阅的频道,如下所示:
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
NSMutableArray *array = [NSMutableArray array];
for (Room *aRoom in rooms) {
NSString *strChannel = [NSString stringWithFormat:@"pr_%@", aRoom.roomId];
[array addObject:strChannel];
}
[currentInstallation setChannels:array];
Run Code Online (Sandbox Code Playgroud)
在我的例子中,频道是"pr_4".
当我在这个频道上推送一些东西时,解析仪表板告诉我没有人订阅频道"pr_4".我不明白我做错了什么.
parse-platform ×10
ios ×6
android ×2
objective-c ×2
async-await ×1
c# ×1
channel ×1
cloud ×1
facebook ×1
int ×1
ios7 ×1
iphone ×1
paypal ×1
while-loop ×1
xamarin ×1