我有一个使用Xamarin.Forms的应用程序,目标是IOS,Android和WP 8.
我的应用程序中需要推送通知功能.
我看过pushsharp演示,看起来很有希望.但我见过的所有代码都是针对每个平台单独完成的.
我希望它可以在App.cs中的某个Xamarin.Forms项目中完成,这样我就不需要重复注册设备的代码,并处理如何处理推送通知.
任何帮助将不胜感激.欢迎提供示例代码或教程参考.
我已经开发了一个应用程序,因为我实现了推送通知.目前它在苹果商店上市.iOS 9推送工作正常,但iOS 10之后无法正常工作.
代码有什么问题?
我需要在我的应用程序中实现推送通知功能.探索一些选择.
谷歌最近推荐使用Firebase平台,但这不是一个完全免费的服务.所以我想再次使用GCM.google将来是否会停止对GCM的支持?
android push-notification firebase google-cloud-messaging firebase-cloud-messaging
是否有一个示例项目展示了如何在iPhone上使用APNS以及如何设置内容?我目前正在查看文档,但是有一些工作代码可以分开并看看它们如何一起工作会很好吗?
我似乎无法使用谷歌或在iPhone开发中心找到任何东西.
当我发送多个推送通知时,我需要它们全部显示在发送时间desc的通知栏中.我知道我应该使用独特的通知 - 我试图生成随机数,但这并没有解决我的问题,因为我需要它们被订购.我试图使用AtomicInt,但仍然没有达到预期的效果.
package com.mypackage.lebadagency;
import java.util.concurrent.atomic.AtomicInteger;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.widget.RemoteViews;
import com.google.android.gms.gcm.GoogleCloudMessaging;
public class GCMNotificationIntentService extends IntentService {
private AtomicInteger c = new AtomicInteger(0);
public int NOTIFICATION_ID = c.incrementAndGet();
private NotificationManager mNotificationManager;
NotificationCompat.Builder builder;
public GCMNotificationIntentService() {
super("GcmIntentService");
}
public static final String TAG = "GCMNotificationIntentService";
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现后台推送通知处理,但是我在确定用户是否从发送的推送通知中打开应用程序时遇到了问题,而不是从图标打开它.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
//************************************************************
// I only want this called if the user opened from swiping the push notification.
// Otherwise I just want to update the local model
//************************************************************
if(applicationState != UIApplicationStateActive) {
MPOOpenViewController *openVc = [[MPOOpenViewController alloc] init];
[self.navigationController pushViewController:openVc animated:NO];
} else {
///Update local model
}
completionHandler(UIBackgroundFetchResultNewData);
}
Run Code Online (Sandbox Code Playgroud)
使用此代码,无论用户如何打开应用程序,应用程序都会打开MPOOpenViewController.我怎样才能使视图控制器只有在他们通过刷通知打开应用程序时才会被推送?
使用相同的代码,这适用于iOS 6,但使用新的iOS 7方法,它的行为并不像我想要的那样.
编辑:我正在尝试在iOS 7上运行应用程序,我们不支持iOS 7之前的任何版本.我在方法的iOS 6版本中使用了相同的确切代码(没有完成处理程序)并且它表现得很好我希望它的方式.你要刷通知,这将被调用.如果从图标打开,则永远不会调用该方法.
push-notification apple-push-notifications uiapplicationdelegate ios ios7
我正在使用Xcode 5.我正在使用iOS中的推送通知.我在后台模式和前台模式下获得了令人满意的结果,可以在iOS设备上轻松调试.
但问题是当app处于关闭状态并通过推送通知点击启动但我不知道如何在这种情况下调试.我知道Xcode 4的解决方案,但不知道Xcode 5的解决方案.
那么有什么解决方案可以通过推送通知启动Xcode 5并调试应用程序吗?提供在这种情况下调试的步骤.
当我收到这样的远程通知时,我实现了一个打开AlertView的函数:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){
var notifiAlert = UIAlertView()
var NotificationMessage : AnyObject? = userInfo["alert"]
notifiAlert.title = "TITLE"
notifiAlert.message = NotificationMessage as? String
notifiAlert.addButtonWithTitle("OK")
notifiAlert.show()
}
Run Code Online (Sandbox Code Playgroud)
但NotificationMessage总是零.
我的json有效负载如下所示:
{"aps":{"alert":"Testmessage","badge":"1"}}
Run Code Online (Sandbox Code Playgroud)
我正在使用Xcode 6,Swift和我正在为iOS8开发.我现在搜索了几个小时,但没有找到任何有用的信息.通知工作完美..如果我点击它,将打开alertview.我的问题是,我无法从userInfo中获取数据.
我目前正在测试TestFlight中的应用程序并需要生产APNs证书才能测试Firebase中的通知.
我已按照此视频中的所有步骤成功配置了开发APNs证书:https://www.youtube.com/watch?v = LBw5tuTvKd4
我还检查了Firebase支持指南后的步骤.虽然我注意到Apple开发者网站自编写本指南以来略有变化:https: //firebase.google.com/docs/cloud-messaging/ios/certs#configure_an_app_id_for_push_notifications
我使用与开发证书相同的方法在developer.apple.com上生成了生产APNs证书,但是当我尝试将.p12文件上传到Firebase时,它给出了以下错误:
"证书环境不匹配.确保您获得了正确的开发或生产APNS证书."
我肯定会上传从生产APNS证书生成的.p12,我还需要为生产证书做些什么吗?
push-notification apple-push-notifications ios firebase firebase-cloud-messaging
如何检查用户是否在ios 9或ios 10上启用了远程通知?
如果用户未允许或单击否我想切换询问是否要启用通知的消息.