小编Beu*_*Beu的帖子

iOS NotificationServiceExtension 不起作用

我在我的应用程序中启用了 NotificationServiceExtension。并做了以下

  1. 在框架、库和嵌入式内容下添加了 .apppex
  2. 确认两个部署目标版本都是 12.0
  3. Sending mutable-content": 1 在我的 apns 通知负载中
  4. 以下是我的 NotificationService 的didReceiveNotificationRequest方法

    - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    
    self.bestAttemptContent = [request.content mutableCopy];
    
    self.bestAttemptContent.badge = @20;
    self.contentHandler(self.bestAttemptContent);
    
    Run Code Online (Sandbox Code Playgroud)

    }

不知道我在这里缺少什么。搜索并关注了这么多文件。似乎没有任何工作。

我正在使用 XCode 11.2.1 和带有 ios 版本 13 的真实设备。

objective-c ios unnotificationserviceextension

9
推荐指数
0
解决办法
95
查看次数

如何在reactjs中选择要复制的文本而不触发点击事件

我正在使用反应表。我已经为一列定义了 onRowClick() 函数。这里选择文本应该突出显示文本,点击必须重定向到另一个页面。现在,当我尝试选择文本时,它会被重定向。如何在不触发点击事件的情况下选择文本?

以下是我的 onRowClick 函数:

onRowClick = (state, rowInfo, columnInfo) => {
  return {
    onClick: (e, handleOriginal) => {
      if (columnInfo.id) {
        this.props.history.push(`/downloads/${rowInfo.original.id}`);
      } else if (handleOriginal) {
        handleOriginal();
      }
    }
  };
}
Run Code Online (Sandbox Code Playgroud)

以下是我的反应表组件:

<ReactTable
  manual
  getTdProps = {this.onRowClick}
  data = {results}
  onFetchData = {this.onFetchData}
  sortable = {false}
  showPagination = {false}
  noDataText = 'no data found'
  columns = {[
   {
     Header: 'Id',
     maxWidth: 50,
     accessor: "id",
     Cell: (props) => <span className="btn-link pointer">{props.value} </span>
   },
   {
     Header: 'Processed on',
     maxWidth: …
Run Code Online (Sandbox Code Playgroud)

events reactjs

7
推荐指数
1
解决办法
1620
查看次数

Firebase - getToken() 抛出不支持的 MIME 类型

我有一个react-create-app应用程序,其中我使用firebase进行推送通知。最近我将firebase从 8.* 升级到 9.*。获取推送令牌时,会抛出以下错误:

FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('https://9fd5-49-204-137-92.ngrok.io/firebase-cloud-messaging-push-scope') with script ('https://9fd5-49-204-137-92.ngrok.io/firebase-messaging-sw.js'): The script has an unsupported MIME type ('text/html'). (messaging/failed-service-worker-registration).
Run Code Online (Sandbox Code Playgroud)

在 firebase.js 中,我有以下代码集,它会引发上述错误

    import { initializeApp } from "firebase/app"
import { getToken, getMessaging, onMessage } from "firebase/messaging";

const message_key = "key"

var firebaseConfig = {
  apiKey: "apikey",
  authDomain: "authdomain",
  projectId: "project-app",
  storageBucket: "******.com",
  messagingSenderId: "id",
  appId: "appid",
  measurementId: "mid"
};

const firebaseApp = …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs service-worker firebase-cloud-messaging

7
推荐指数
1
解决办法
708
查看次数

我想在应用程序的非活动模式下接收通知时在主应用程序图标上增加徽章

我正在使用 React-native iOS 开发一个聊天应用程序。当收到通知时,当应用程序被用户杀死或强制退出时,我想在主应用程序图标上做一个徽章增量。当应用程序处于后台模式时,它运行良好。但是当应用程序处于非活动状态时不会调用didReceiveRemoteNotification方法。对此有什么想法吗?我在AppDelegate的didReceiveRemoteNotification方法中添加了代码。

在 AppDelegate 文件中添加了以下代码集

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
      [RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
    }

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
      [RNNotifications didFailToRegisterForRemoteNotificationsWithError:error];
    }

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    NSLog(@"APPDELEGATE: didReceiveRemoteNotification:fetchCompletionHandler %@", userInfo);
  int badge = (int) application.applicationIconBadgeNumber;
  if ( application.applicationState == UIApplicationStateInactive ) {
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge+1];
  }
  else if(application.applicationState == UIApplicationStateBackground) {
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge+1];
  }
  else if(application.applicationState == UIApplicationStateActive) {
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge+1];
  }
  completionHandler(UIBackgroundFetchResultNewData);
}
Run Code Online (Sandbox Code Playgroud)

objective-c push-notification apple-push-notifications ios react-native

6
推荐指数
1
解决办法
1097
查看次数

Rails:pagy 忽略 attr_accessor

我需要在索引页上显示 attr_accessor 值。对于分页,我使用 pagey gem。下面是代码块:

def index
    @posts = Post.all
    @posts.map do |post|
      post_info = get_post_info(post.url)
      post.update_attribute(:icon, post_info["icon"])
      post.update_attribute(:subtitle, post_info["subtitle"])
    end
    print @posts[0].icon
    @pagy, @posts = pagy(@posts)    
  end
Run Code Online (Sandbox Code Playgroud)

第一篇文章的打印图标在控制器中提供了正确的 url。

当我post.icon在视图文件中使用时,它为零。如果我直接发送@posts而不使用pagey,它会按预期工作。怎么解决这个问题呢?

这是没有 pagey 的代码

def index
    @posts = Post.all
    @posts.map do |post|
      post_info = get_post_info(post.url)
      post.update_attribute(:icon, post_info["icon"])
      post.update_attribute(:subtitle, post_info["subtitle"])
    end
  end
Run Code Online (Sandbox Code Playgroud)

这是我的视图代码:

索引.html.erb

<div class="">
      <%= render partial: "posts/index", collection: @posts, as: :post %>
  </div> 
Run Code Online (Sandbox Code Playgroud)

_index.html.erb如下

  <div class="flex mb-4">
    <div class="rounded float-left mr-3 my-3" style=";">
      <% if !post.icon.nil? …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails pagy

6
推荐指数
0
解决办法
150
查看次数

带有 redis 缓存存储的 Rails Keycloak gem 抛出 ActionDispatch::Cookies::CookieOverflow

我在 Rails 应用程序中使用 Keycloak gem。根据 keycloak 文档,keycloak 使用 cookie。在我的应用程序中,我使用 Redis 缓存存储来存储这些 cookie。

config.session_store :cache_store, key: ENV['APP_SESSION_KEY']
Run Code Online (Sandbox Code Playgroud)

它抛出以下

raise CookieOverflow if options[:value].bytesize > MAX_COOKIE_SIZE

ActionDispatch::Cookies::CookieOverflow
Run Code Online (Sandbox Code Playgroud)

如果我使用active_record_store它工作正常。但我真的需要使用redis_cache_store

我该如何处理?

ruby-on-rails session-cookies redis-cache rails-activerecord keycloak

5
推荐指数
0
解决办法
84
查看次数

如何自定义 UICollectionView Cell 以显示图像网格,如附件所示?

我想显示附件中所示的图像。我如何使用情节提要和目标 c 来做到这一点?

根据图像计数,需要调整像元大小。

在此输入图像描述 在此输入图像描述 在此输入图像描述 在此输入图像描述 图像网格视图

objective-c storyboard ios uicollectionview uicollectionviewcell

5
推荐指数
1
解决办法
266
查看次数

如何在ios目标c中创建嵌套滚动视图?

我需要一个屏幕中的两个垂直滚动视图。外滚动到达特定点时应停止滚动。(页面的倾斜到达顶部)。当外部滚动停止滚动时,内部滚动视图应该开始滚动。我怎样才能让它工作?

在此处输入图片说明

nested objective-c scrollview ios

5
推荐指数
0
解决办法
38
查看次数

在nginx中配置同一个域中的多台服务器

需要配置nginx在同一个域中有多个服务。

我的 nginx.conf 文件如下

server {
   listen 80;
   listen [::]:80;
   server_name www.example.com example.com;
   access_log  /var/log/nginx/host.access.log  main;

   location ^~ /.well-known/acme-challenge/ {
     alias /var/www/acme-challenge/;
   }
   return 301 https://$host$request_uri;
}

server {
   listen 443;
   listen [::]:443;
   server_name www.example.com example.com;

   ssl_certificate      /etc/letsencrypt/live/example.com/fullchain.pem;
   ssl_certificate_key  /etc/letsencrypt/live/example.com/privkey.pem;
   ssl on;
   access_log  /var/log/nginx/host.access.log  main;
#
# # Enable server-side protection against BEAST attacks
#   ssl_protocols TLSv1.2;
#
   ssl_trusted_certificate /etc/letsencrypt/live/example.com/fullchain.pem;

   location ^~ /.well-known/acme-challenge/ {
     alias /var/www/acme-challenge/;
   }

   location /cms/ {
       proxy_pass http://cms-container:1337;
       rewrite ^/sdcms/?(.*)$ /$1 break;
       proxy_set_header   Host $host;
       proxy_set_header …
Run Code Online (Sandbox Code Playgroud)

nginx

5
推荐指数
0
解决办法
44
查看次数